home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term.c < prev    next >
C/C++ Source or Header  |  1996-01-23  |  73KB  |  2,358 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: term.c,v 1.72 1995/12/11 23:14:06 drd Exp $";
  3. #endif
  4.  
  5.  
  6. /* GNUPLOT - term.c */
  7. /*
  8.  * Copyright (C) 1986 - 1993   Thomas Williams, Colin Kelley
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software is provided "as is" without express or implied warranty.
  21.  *
  22.  *
  23.  * AUTHORS
  24.  * 
  25.  *   Original Software:
  26.  *     Thomas Williams,  Colin Kelley.
  27.  * 
  28.  *   Gnuplot 2.0 additions:
  29.  *       Russell Lang, Dave Kotz, John Campbell.
  30.  *
  31.  *   Gnuplot 3.0 additions:
  32.  *       Gershon Elber and many others.
  33.  * 
  34.  * There is a mailing list for gnuplot users. Note, however, that the
  35.  * newsgroup 
  36.  *    comp.graphics.gnuplot 
  37.  * is identical to the mailing list (they
  38.  * both carry the same set of messages). We prefer that you read the
  39.  * messages through that newsgroup, to subscribing to the mailing list.
  40.  * (If you can read that newsgroup, and are already on the mailing list,
  41.  * please send a message info-gnuplot-request@dartmouth.edu, asking to be
  42.  * removed from the mailing list.)
  43.  *
  44.  * The address for mailing to list members is
  45.  *       info-gnuplot@dartmouth.edu
  46.  * and for mailing administrative requests is 
  47.  *       info-gnuplot-request@dartmouth.edu
  48.  * The mailing list for bug reports is 
  49.  *       bug-gnuplot@dartmouth.edu
  50.  * The list of those interested in beta-test versions is
  51.  *       info-gnuplot-beta@dartmouth.edu
  52.  */
  53.  
  54. #include <ctype.h>
  55. #include <math.h>
  56. #ifdef NEXT
  57. #include "epsviewe.h"
  58. #endif /* NEXT */
  59. #include "driver.h" /* gets plot.h, setshow.h, bitmap.h */
  60.  
  61. #ifdef OLD_TERMINALS
  62. #include "term.h"
  63. #endif
  64.  
  65. #ifdef _Windows
  66. #ifdef __MSC__
  67. #include <malloc.h>
  68. #else
  69. #include <alloc.h>
  70. #endif
  71. #endif
  72.  
  73. #ifdef vms
  74. /* for a quiet life */
  75. extern sys$crembx();
  76. extern sys$assign();
  77. extern sys$dassgn();
  78. extern sys$qio();
  79. extern sys$qiow();
  80. extern lib$signal();
  81. extern lib$spawn();
  82. #endif
  83.  
  84. /* for use by all drivers */
  85. #define sign(x) ((x) >= 0 ? 1 : -1)
  86.  
  87. /* I'd rather this was ABS(x), but dont fancy going through all the terms */
  88. #ifdef abs /* SAS/C and DECC/AXP-VMS have abs() as a macro */
  89. #undef abs
  90. #endif
  91. #define abs(x) ((x) >= 0 ? (x) : -(x))
  92.  
  93.  
  94. #ifndef max    /* GCC uses inline functions */
  95. #define max(a,b) ((a) > (b) ? (a) : (b))
  96. #endif
  97. #ifndef min
  98. #define min(a,b) ((a) < (b) ? (a) : (b))
  99. #endif
  100.  
  101. TBOOLEAN term_init;            /* true if terminal has been initialized */
  102. TBOOLEAN term_graphics=FALSE;    /* true if terminal is in graphics mode */
  103. TBOOLEAN term_suspended=FALSE;   /* we have suspended the driver, in multiplot mode */
  104. extern FILE *outfile;
  105. extern char outstr[];
  106. extern float xsize, ysize;
  107.  
  108. void do_point __P((unsigned int x, unsigned int y, int number));
  109. void line_and_point __P((unsigned int x, unsigned int y, int number));
  110. void do_arrow __P((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head));
  111. int null_text_angle __P((int ang));
  112. int null_justify_text __P((enum JUSTIFY just));
  113. int null_scale __P((double x, double y));
  114. int do_scale __P((double x, double y));
  115. void options_null __P((void));
  116. void UNKNOWN_null __P((void));
  117.  
  118. #ifdef __ZTC__
  119. char *ztc_init();
  120. /* #undef TGIF */
  121. #endif
  122.  
  123. #if defined(MSDOS)||defined(ATARI)||defined(MTOS)||defined(OS2)||defined(_Windows)||defined(DOS386)
  124. void reopen_binary();
  125. #define REOPEN_BINARY
  126. #endif
  127. #ifdef vms
  128. char *vms_init();
  129. void vms_reset();
  130. void term_mode_tek();
  131. void term_mode_native();
  132. void term_pasthru();
  133. void term_nopasthru();
  134. void reopen_binary();
  135. void fflush_binary();
  136. #define REOPEN_BINARY
  137. #endif
  138.  
  139. /* This is needed because the unixplot library only writes to stdout. */
  140. #ifdef UNIXPLOT
  141. FILE save_stdout;
  142. #endif
  143. int unixplot=0;
  144.  
  145. #if defined(MTOS) || defined(ATARI)
  146. int aesid = -1;
  147. #endif
  148.  
  149. #define NICE_LINE        0
  150. #define POINT_TYPES        6
  151.  
  152.  
  153. void do_point(x,y,number)
  154. unsigned int x,y;
  155. int number;
  156. {
  157. register int htic,vtic;
  158. register struct termentry *t = term;
  159.  
  160.      if (number < 0) {        /* do dot */
  161.         (*t->move)(x,y);
  162.         (*t->vector)(x,y);
  163.         return;
  164.     }
  165.  
  166.     number %= POINT_TYPES;
  167.     htic = (pointsize*t->h_tic/2);    /* should be in term_tbl[] in later version */
  168.     vtic = (pointsize*t->v_tic/2);    
  169.  
  170.     switch(number) {
  171.         case 0: /* do diamond */ 
  172.                 (*t->move)(x-htic,y);
  173.                 (*t->vector)(x,y-vtic);
  174.                 (*t->vector)(x+htic,y);
  175.                 (*t->vector)(x,y+vtic);
  176.                 (*t->vector)(x-htic,y);
  177.                 (*t->move)(x,y);
  178.                 (*t->vector)(x,y);
  179.                 break;
  180.         case 1: /* do plus */ 
  181.                 (*t->move)(x-htic,y);
  182.                 (*t->vector)(x-htic,y);
  183.                 (*t->vector)(x+htic,y);
  184.                 (*t->move)(x,y-vtic);
  185.                 (*t->vector)(x,y-vtic);
  186.                 (*t->vector)(x,y+vtic);
  187.                 break;
  188.         case 2: /* do box */ 
  189.                 (*t->move)(x-htic,y-vtic);
  190.                 (*t->vector)(x-htic,y-vtic);
  191.                 (*t->vector)(x+htic,y-vtic);
  192.                 (*t->vector)(x+htic,y+vtic);
  193.                 (*t->vector)(x-htic,y+vtic);
  194.                 (*t->vector)(x-htic,y-vtic);
  195.                 (*t->move)(x,y);
  196.                 (*t->vector)(x,y);
  197.                 break;
  198.         case 3: /* do X */ 
  199.                 (*t->move)(x-htic,y-vtic);
  200.                 (*t->vector)(x-htic,y-vtic);
  201.                 (*t->vector)(x+htic,y+vtic);
  202.                 (*t->move)(x-htic,y+vtic);
  203.                 (*t->vector)(x-htic,y+vtic);
  204.                 (*t->vector)(x+htic,y-vtic);
  205.                 break;
  206.         case 4: /* do triangle */ 
  207.                 (*t->move)(x,y+(4*vtic/3));
  208.                 (*t->vector)(x-(4*htic/3),y-(2*vtic/3));
  209.                 (*t->vector)(x+(4*htic/3),y-(2*vtic/3));
  210.                 (*t->vector)(x,y+(4*vtic/3));
  211.                 (*t->move)(x,y);
  212.                 (*t->vector)(x,y);
  213.                 break;
  214.         case 5: /* do star */ 
  215.                 (*t->move)(x-htic,y);
  216.                 (*t->vector)(x-htic,y);
  217.                 (*t->vector)(x+htic,y);
  218.                 (*t->move)(x,y-vtic);
  219.                 (*t->vector)(x,y-vtic);
  220.                 (*t->vector)(x,y+vtic);
  221.                 (*t->move)(x-htic,y-vtic);
  222.                 (*t->vector)(x-htic,y-vtic);
  223.                 (*t->vector)(x+htic,y+vtic);
  224.                 (*t->move)(x-htic,y+vtic);
  225.                 (*t->vector)(x-htic,y+vtic);
  226.                 (*t->vector)(x+htic,y-vtic);
  227.                 break;
  228.     }
  229. }
  230.  
  231.  
  232. /*
  233.  * general point routine
  234.  */
  235. void line_and_point(x,y,number)
  236. unsigned int x,y;
  237. int number;
  238. {
  239.     /* temporary(?) kludge to allow terminals with bad linetypes 
  240.         to make nice marks */
  241.  
  242.     (*term->linetype)(NICE_LINE);
  243.     do_point(x,y,number);
  244. }
  245.  
  246. /* 
  247.  * general arrow routine
  248.  *
  249.  * I set the angle between the arrowhead and the line 15 degree.
  250.  * The length of arrowhead varies depending on the line length 
  251.  * within the the range [0.3*(the-tic-length), 2*(the-tic-length)].
  252.  * No head is printed if the arrow length is zero.
  253.  *
  254.  *            Yasu-hiro Yamazaki(hiro@rainbow.physics.utoronto.ca)
  255.  *            Jul 1, 1993
  256.  */
  257.  
  258. #define COS15 (0.96593)         /* cos of 15 degree */
  259. #define SIN15 (0.25882)         /* sin of 15 degree */
  260.  
  261. #define HEAD_LONG_LIMIT  (2.0)  /* long  limit of arrowhead length */
  262. #define HEAD_SHORT_LIMIT (0.3)  /* short limit of arrowhead length */
  263.                                 /* their units are the "tic" length */ 
  264.  
  265. #define HEAD_COEFF  (0.3)       /* default value of head/line length ratio */
  266.  
  267. void do_arrow(sx, sy, ex, ey, head)
  268.     unsigned int sx,sy;            /* start point */
  269.     unsigned int ex, ey;            /* end point (point of arrowhead) */
  270.     TBOOLEAN head;
  271. {
  272.     register struct termentry *t = term;
  273.     float len_tic = ((double) (t->h_tic + t->v_tic) )/2.0;
  274.                                        /* average of tic sizes */
  275.     double dx = (double)sx - (double)ex;
  276.     double dy = (double)sy - (double)ey;     /* (dx,dy) : vector from end to start */
  277.     double len_arrow = sqrt( dx*dx + dy*dy );
  278.  
  279.     /* draw the line for the arrow. That's easy. */
  280.     (*t->move)(sx, sy);
  281.     (*t->vector)(ex, ey);
  282.  
  283.     if (head && len_arrow != 0.0) { /* no head for arrows whih length=0 */
  284.       /* now calc the head_coeff */
  285.       double  coeff_shortest = len_tic*HEAD_SHORT_LIMIT/len_arrow;
  286.       double  coeff_longest  = len_tic*HEAD_LONG_LIMIT/len_arrow;
  287.       double  head_coeff = max( coeff_shortest, 
  288.                                 min( HEAD_COEFF, coeff_longest) );
  289.     /* now draw the arrow head. */
  290.     /* we put the arrowhead marks at 15 degrees to line */
  291.       int x,y;            /* one endpoint */
  292.  
  293.       x = (int)( ex + ( COS15*dx - SIN15*dy) * head_coeff );
  294.       y = (int)( ey + ( SIN15*dx + COS15*dy) * head_coeff );
  295.       (*t->move)(x,y);
  296.       (*t->vector)(ex,ey);
  297.  
  298.       x = (int)( ex + ( COS15*dx + SIN15*dy) * head_coeff );
  299.       y = (int)( ey + (-SIN15*dx + COS15*dy) * head_coeff );
  300.      (*t->vector)(x,y);
  301.     }
  302. }
  303.  
  304. #if 0 /* oiginal routine */
  305. #define ROOT2 (1.41421)        /* sqrt of 2 */
  306.  
  307. static void org_do_arrow(sx, sy, ex, ey, head)
  308.     int sx,sy;            /* start point */
  309.     int ex, ey;            /* end point (point of arrowhead) */
  310.     TBOOLEAN head;
  311. {
  312.     register struct termentry *t = term;
  313.     int len = (t->h_tic + t->v_tic)/2; /* arrowhead size = avg of tic sizes */
  314.  
  315.     /* draw the line for the arrow. That's easy. */
  316.     (*t->move)(sx, sy);
  317.     (*t->vector)(ex, ey);
  318.  
  319.     if (head) {
  320.     /* now draw the arrow head. */
  321.     /* we put the arrowhead marks at 45 degrees to line */
  322.        if (sx == ex) {
  323.        /* vertical line, special case */
  324.           int delta = ((float)len / ROOT2 + 0.5);
  325.           if (sy < ey)
  326.               delta = -delta;    /* up arrow goes the other way */
  327.           (*t->move)(ex - delta, ey + delta);
  328.           (*t->vector)(ex,ey);
  329.           (*t->vector)(ex + delta, ey + delta);
  330.        } else {
  331.           int dx = sx - ex;
  332.           int dy = sy - ey;
  333.           double coeff = len / sqrt(2.0*((double)dx*(double)dx 
  334.                    + (double)dy*(double)dy));
  335.           int x,y;            /* one endpoint */
  336.  
  337.           x = (int)( ex + (dx + dy) * coeff );
  338.           y = (int)( ey + (dy - dx) * coeff );
  339.           (*t->move)(x,y);
  340.           (*t->vector)(ex,ey);
  341.  
  342.           x = (int)( ex + (dx - dy) * coeff );
  343.           y = (int)( ey + (dy + dx) * coeff );
  344.           (*t->vector)(x,y);
  345.        }
  346.     }
  347. }
  348. #endif /* original routine */
  349.  
  350.  
  351. #if !defined(OLD_TERMINALS)
  352.  
  353. #define TERM_PROTO
  354. #define TERM_BODY
  355. #define TERM_PUBLIC static
  356.  
  357. #include "term.h"
  358.  
  359. #undef TERM_PROTO
  360. #undef TERM_BODY
  361. #undef TERM_PUBLIC
  362.  
  363. #else /* OLD_TERMINALS */
  364.  
  365. /* temporary defines for new terminal file format */
  366.  
  367. #define TERM_PROTO
  368. #define TERM_BODY
  369. #define TERM_PUBLIC static
  370.  
  371. #ifdef DUMB                    /* paper or glass dumb terminal */
  372. #include "term/dumb.trm"
  373. #endif
  374.  
  375.  
  376. #ifndef _Windows
  377. # ifdef PC            /* all PC types except MS WINDOWS*/
  378. #  include "term/pc.trm"
  379. # endif
  380. #else
  381. #  include "term/win.trm"
  382. #endif
  383.  
  384. #ifdef __ZTC__
  385. #include "term/fg.trm"
  386. #endif
  387.  
  388. #ifdef DJSVGA
  389. #include "term/djsvga.trm"    /* DJGPP SVGA */
  390. #endif
  391.  
  392. #ifdef EMXVGA
  393. #include "term/emxvga.trm"    /* EMX VGA */
  394. #endif
  395.  
  396. #ifdef OS2PM                    /* os/2 presentation manager */
  397. #include "term/pm.trm"
  398. #endif
  399.  
  400. #if defined(ATARI) || defined(MTOS)    /* ATARI-ST */
  401. #include "term/atarivdi.trm"
  402. #ifdef MTOS
  403. #include "term/multitos.trm"
  404. #endif
  405. #include "term/atariaes.trm"
  406. #endif
  407.  
  408. /*
  409.    all TEK types (TEK,BITGRAPH,KERMIT,VTTEK,SELANAR) are ifdef'd in tek.trm,
  410.    but most require various TEK routines.  Hence TEK must be defined for
  411.    the others to compile.
  412. */
  413. #ifdef BITGRAPH
  414. # ifndef TEK
  415. #  define TEK
  416. # endif
  417. #endif
  418.  
  419. #ifdef SELENAR
  420. # ifndef TEK
  421. #  define TEK
  422. # endif
  423. #endif
  424.  
  425. #ifdef KERMIT
  426. # ifndef TEK
  427. #  define TEK
  428. # endif
  429. #endif
  430.  
  431. #ifdef LN03P
  432. # ifndef TEK
  433. #  define TEK
  434. # endif
  435. #endif
  436.  
  437. #ifdef VTTEK
  438. # ifndef TEK
  439. #  define TEK
  440. # endif
  441. #endif
  442.  
  443. #ifdef T410X        /* Tektronix 4106, 4107, 4109 and 420x terminals */
  444. #include "term/t410x.trm"
  445. #endif
  446.  
  447. #ifdef TEK            /* all TEK types, TEK, BBN, SELANAR, KERMIT, VTTEK */
  448. #include "term/tek.trm"
  449. #endif
  450.  
  451. #ifdef OKIDATA
  452. #define EPSONP
  453. #endif
  454.  
  455. #ifdef EPSONP    /* bit map types, EPSON, NEC, PROPRINTER, STAR Color */
  456. #include "term/epson.trm"
  457. #endif
  458.  
  459. #ifdef HP500C  /* HP 500 deskjet Colour */
  460. #include "term/hp500c.trm"
  461. #endif
  462.  
  463. #ifdef HPLJII        /* HP LaserJet II */
  464. #include "term/hpljii.trm"
  465. #endif
  466.  
  467. #ifdef PCL /* HP LaserJet III in HPGL mode */
  468. #  ifndef HPGL
  469. #    define HPGL
  470. #  endif
  471. #endif
  472.  
  473. #ifdef HPPJ        /* HP PaintJet */
  474. #include "term/hppj.trm"
  475. #endif
  476.  
  477. #ifdef FIG            /* Fig 3.1 Interactive graphics program */
  478. #include "term/fig.trm"
  479. #include "term/bigfig.trm"
  480. #endif
  481.   
  482. #ifdef GPR              /* Apollo Graphics Primitive Resource (fixed-size window) */
  483. #include "term/gpr.trm"
  484. #endif /* GPR */
  485.  
  486. #ifdef APOLLO           /* Apollo Graphics Primitive Resource (resizable window) */
  487. #include "term/apollo.trm"
  488. #endif /* APOLLO */
  489.  
  490. #ifdef IMAGEN        /* IMAGEN printer */
  491. #include "term/imagen.trm"
  492. #endif
  493.  
  494. #ifdef MIF            /* Framemaker MIF  driver */
  495. #include "term/mif.trm"
  496. #endif
  497.  
  498. #ifdef MF            /* METAFONT driver */
  499. #include "term/metafont.trm"
  500. #endif
  501.  
  502. #ifdef TEXDRAW
  503. #include "term/texdraw.trm"
  504. #endif
  505.  
  506. #ifdef EEPIC        /* EEPIC (LATEX) type */
  507. #include "term/eepic.trm"
  508. # ifndef LATEX
  509. #  define LATEX
  510. # endif
  511. #endif
  512.  
  513. #ifdef EMTEX        /* EMTEX (LATEX for PC) type */
  514. # ifndef LATEX
  515. #  define LATEX
  516. # endif
  517. #endif
  518.  
  519. #ifdef LATEX        /* LATEX type */
  520. #include "term/latex.trm"
  521. #endif
  522.  
  523. #ifdef GPIC        /* GPIC (groff) type */ 
  524. #include "term/gpic.trm"
  525. #endif
  526.  
  527. #ifdef PBM        /* PBMPLUS portable bitmap */
  528. #include "term/pbm.trm"
  529. #endif
  530.  
  531. #ifdef POSTSCRIPT    /* POSTSCRIPT type */
  532. #include "term/post.trm"
  533. #include "term/enhpost.trm"
  534. #endif
  535.  
  536. #ifdef GRASS              /* GRASS (geographic info system) monitor */
  537. #include "term/grass.trm"
  538. #endif /* GRASS */
  539.  
  540. #ifdef PRESCRIBE    /* PRESCRIBE type */
  541. #include "term/kyo.trm"
  542. #endif
  543.  
  544. /* note: this must come after term/post.trm */
  545. #ifdef PSLATEX        /* LaTeX with embedded PostScript */
  546. #include "term/pslatex.trm"
  547. #endif
  548.  
  549. /* note: this must come after term/pslatex.trm */
  550. #ifdef PSTEX        /* Generic TeX with embedded PostScript */
  551. #include "term/pstex.trm"
  552. #endif
  553.  
  554. #ifdef PSTRICKS
  555. #include "term/pstricks.trm"
  556. #endif
  557.  
  558. #ifdef TPIC        /* TPIC (LATEX) type */
  559. #include "term/tpic.trm"
  560. # ifndef LATEX
  561. #  define LATEX
  562. # endif
  563. #endif
  564.  
  565. #ifdef UNIXPC     /* unix-PC  ATT 7300 or 3b1 machine */
  566. #include "term/unixpc.trm"
  567. #endif /* UNIXPC */
  568.  
  569. #ifdef AED
  570. #include "term/aed.trm"
  571. #endif /* AED */
  572.  
  573. #ifdef AIFM
  574. #include "term/ai.trm"
  575. #endif /* AIFM */
  576.  
  577. #ifdef COREL
  578. #include "term/corel.trm"
  579. #endif /* COREL */
  580.  
  581. #ifdef CGI
  582. #include "term/cgi.trm"
  583. #endif /* CGI */
  584.  
  585. #ifdef DEBUG
  586. #include "term/debug.trm"
  587. #endif /* DEBUG */
  588.  
  589. #ifdef EXCL
  590. #include "term/excl.trm"
  591. #endif /* EXCL */
  592.  
  593. #ifdef HP2648
  594. /* also works for HP2647 */
  595. #include "term/hp2648.trm"
  596. #endif /* HP2648 */
  597.  
  598. #ifdef HP26
  599. #include "term/hp26.trm"
  600. #endif /* HP26 */
  601.  
  602. #ifdef HP75
  603. #ifndef HPGL
  604. #define HPGL
  605. #endif
  606. #endif
  607.  
  608. #ifdef HP7550
  609. #ifndef HPGL
  610. #define HPGL
  611. #endif
  612. #endif
  613.  
  614. /* HPGL - includes HP75, HP7550 and HPLJIII in HPGL mode */
  615. #ifdef HPGL
  616. #include "term/hpgl.trm"
  617. #endif /* HPGL */
  618.  
  619. /* Roland DXY800A plotter driver by Martin Yii, eln557h@monu3.OZ 
  620.     and Russell Lang, rjl@monu1.cc.monash.oz */
  621. #ifdef DXY800A
  622. #include "term/dxy.trm"
  623. #endif /* DXY800A */
  624.  
  625. #ifdef GIF
  626. #include "term/gdgif.trm"
  627. #endif /* GIF */
  628.  
  629.  
  630. #ifdef IRIS4D
  631. #include "term/iris4d.trm"
  632. #endif /* IRIS4D */
  633.  
  634. #ifdef NEXT
  635. #include "term/next.trm"
  636. #endif /* NEXT */
  637.  
  638. #ifdef QMS
  639. #include "term/qms.trm"
  640. #endif /* QMS */
  641.  
  642. #ifdef REGIS
  643. #include "term/regis.trm"
  644. #endif /* REGIS */
  645.  
  646. #ifdef RGIP
  647. #include "term/rgip.trm"
  648. #endif /* RGIP UNIPLEX */
  649.  
  650. #ifdef MGR
  651. #include "term/mgr.trm"
  652. #endif /* MGR */
  653.  
  654. #ifdef SUN
  655. #include "term/sun.trm"
  656. #endif /* SUN */
  657.  
  658. #ifdef VWS
  659. #include "term/vws.trm"
  660. #endif /* VWS */
  661.  
  662. #ifdef V384
  663. #include "term/v384.trm"
  664. #endif /* V384 */
  665.  
  666. #ifdef TGIF
  667. #include "term/tgif.trm"
  668. #endif /* TGIF */
  669.  
  670. #ifdef UNIXPLOT
  671. #ifdef GNUGRAPH
  672. #include "term/gnugraph.trm"
  673. #else
  674. #include "term/unixplot.trm"
  675. #endif /* GNUGRAPH */
  676. #endif /* UNIXPLOT */
  677.  
  678. #ifdef X11
  679. #include "term/x11.trm"
  680. #include "term/xlib.trm"
  681. #endif /* X11 */
  682.  
  683. #ifdef LINUX
  684. #include "term/linux.trm"
  685. #endif 
  686.  
  687. #ifdef DXF
  688. #include "term/dxf.trm"
  689. #endif /* DXF */
  690.   
  691. #ifdef AMIGASCREEN
  692. #include "term/amiga.trm"
  693. #endif /* AMIGASCREEN */
  694.  
  695. #undef TERM_PROTO
  696. #undef TERM_BODY
  697.  
  698. #endif /* OLD_TERMINALS */
  699.  
  700.  
  701. /* Dummy functions for unavailable features */
  702. /* return success if they asked for default - this simplifies code
  703.  * where param is passed as a param. Client can first pass it here,
  704.  * and only if it fails do they have to see what was trying to be done
  705.  */
  706.  
  707. /* change angle of text.  0 is horizontal left to right.
  708. * 1 is vertical bottom to top (90 deg rotate)  
  709. */
  710. int null_text_angle(ang)
  711. int ang;
  712. {
  713. return (ang==0);
  714. }
  715.  
  716. /* change justification of text.  
  717.  * modes are LEFT (flush left), CENTRE (centred), RIGHT (flush right)
  718.  */
  719. int null_justify_text(just)
  720. enum JUSTIFY just;
  721. {
  722. return (just==LEFT);
  723. }
  724.  
  725.  
  726. /* Change scale of plot.
  727.  * Parameters are x,y scaling factors for this plot.
  728.  * Some terminals (eg latex) need to do scaling themselves.
  729.  */
  730. int null_scale(x,y)
  731. double x;
  732. double y;
  733. {
  734. return FALSE ;    /* can't be done */
  735. }
  736.  
  737. int do_scale(x,y)
  738. double x;
  739. double y;
  740. {
  741. return TRUE ;    /* can be done */
  742. }
  743.  
  744. void options_null()
  745. {
  746.     term_options[0] = '\0';    /* we have no options */
  747. }
  748.  
  749. void UNKNOWN_null()
  750. {
  751. }
  752.  
  753. int set_font_null(s)
  754. char *s;
  755. {
  756.   return FALSE;
  757. }
  758.  
  759. void null_set_pointsize(s)
  760. double s;
  761. {
  762. }
  763.  
  764. /* cast to get rid of useless warnings about UNKNOWN_null */
  765. typedef void (*void_fp)();
  766.  
  767.  
  768. /* temporary macro to allow use of new terminal drivers */
  769. #define TERM_TABLE
  770. #define TERM_TABLE_START(x) ,{
  771. #define TERM_TABLE_END(x)   }
  772.  
  773.  
  774. /*
  775.  * term_tbl[] contains an entry for each terminal.  "unknown" must be the
  776.  *   first, since term is initialized to 0.
  777.  */
  778. struct termentry term_tbl[] = {
  779.     {"unknown", "Unknown terminal type - not a plotting device",
  780.       100, 100, 1, 1,
  781.       1, 1, options_null, UNKNOWN_null, UNKNOWN_null, 
  782.       UNKNOWN_null, null_scale, UNKNOWN_null, (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, 
  783.       (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, null_text_angle, 
  784.       null_justify_text, (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, set_font_null}
  785.  
  786.     ,{"table", "Dump ASCII table of X Y [Z] values to output",
  787.       100, 100, 1, 1,
  788.       1, 1, options_null, UNKNOWN_null, UNKNOWN_null, 
  789.       UNKNOWN_null, null_scale, UNKNOWN_null, (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, 
  790.       (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, null_text_angle, 
  791.       null_justify_text, (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, set_font_null}
  792.  
  793.  
  794. #if !defined(OLD_TERMINALS)
  795.  
  796. #include "term.h"
  797.  
  798. #else /* OLD_TERMINALS */
  799.  
  800. #ifdef AMIGASCREEN
  801.     ,{"amiga", "Amiga Custom Screen",
  802.            AMIGA_XMAX, AMIGA_YMAX, AMIGA_VCHAR, AMIGA_HCHAR, 
  803.            AMIGA_VTIC, AMIGA_HTIC, AMIGA_options, AMIGA_init, AMIGA_reset, 
  804.            AMIGA_text, null_scale, AMIGA_graphics, AMIGA_move, AMIGA_vector,
  805.            AMIGA_linetype, AMIGA_put_text, null_text_angle, 
  806.            AMIGA_justify_text, do_point, do_arrow, AMIGA_set_font}
  807. #endif
  808.  
  809. #ifdef MTOS
  810.     ,{"mtos", "Atari MiNT/MULTITOS/Magic Terminal",
  811.        MTOS_XMAX, MTOS_YMAX, MTOS_VCHAR, MTOS_HCHAR, 
  812.        MTOS_VTIC, MTOS_HTIC, MTOS_options, MTOS_init, MTOS_reset, 
  813.        MTOS_text, null_scale, MTOS_graphics, MTOS_move, MTOS_vector, 
  814.        MTOS_linetype, MTOS_put_text, MTOS_text_angle, 
  815.        MTOS_justify_text, MTOS_point, do_arrow, set_font_null}
  816. #endif
  817.  
  818. #if defined(ATARI) || defined(MTOS)
  819.         ,{"atari", "Atari AES-Terminal",
  820.        ATARI_XMAX, ATARI_YMAX, ATARI_VCHAR, ATARI_HCHAR, 
  821.        ATARI_VTIC, ATARI_HTIC, ATARI_options, ATARI_init, ATARI_reset, 
  822.        ATARI_text, null_scale, ATARI_graphics, ATARI_move, ATARI_vector, 
  823.        ATARI_linetype, ATARI_put_text, ATARI_text_angle, 
  824.        ATARI_justify_text, ATARI_point, do_arrow, set_font_null}
  825.     ,{"vdi", "Atari VDI-Terminal",
  826.        VDI_XMAX, VDI_YMAX, VDI_VCHAR, VDI_HCHAR, 
  827.        VDI_VTIC, VDI_HTIC, VDI_options, VDI_init, VDI_reset, 
  828.        VDI_text, null_scale, VDI_graphics, VDI_move, VDI_vector, 
  829.        VDI_linetype, VDI_put_text, VDI_text_angle, 
  830.        VDI_justify_text, VDI_point, do_arrow, set_font_null}
  831. #endif
  832.  
  833. #ifdef DUMB
  834. #include "dumb.trm"
  835. #endif
  836.  
  837. #ifdef PC
  838. #ifndef _Windows
  839.     ,{"pc", "IBM PC/Clone running DOS",
  840.        PC_XMAX, PC_YMAX, PC_VCHAR, PC_HCHAR,
  841.        PC_VTIC, PC_HTIC, options_null, PC_init, PC_reset,
  842.        PC_text, null_scale, PC_graphics, PC_move, PC_vector,
  843.        PC_linetype, PC_put_text, PC_text_angle,
  844.        null_justify_text, line_and_point, do_arrow, set_font_null}
  845.  
  846. #if 0 /* now all PC (DOS) terminals are combined -- DJL */
  847.  
  848. # ifdef __TURBOC__
  849. #ifdef ATT6300
  850.     ,{"att", "IBM PC/Clone with AT&T 6300 graphics board",
  851.        ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
  852.        ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
  853.        ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
  854.        ATT_linetype, ATT_put_text, ATT_text_angle, 
  855.        ATT_justify_text, line_and_point, do_arrow, set_font_null}
  856. #endif
  857.  
  858.     ,{"egalib", "IBM PC/Clone with EGA graphics board",
  859.        EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  860.        EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
  861.        EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  862.        EGALIB_linetype, EGALIB_put_text, EGALIB_text_angle, 
  863.        EGALIB_justify_text, do_point, do_arrow, set_font_null}
  864.  
  865.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  866.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  867.        HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
  868.        HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
  869.        HERC_linetype, HERC_put_text, MCGA_text_angle, 
  870.        HERC_justify_text, line_and_point, do_arrow, set_font_null}
  871.  
  872.     ,{"mcga", "IBM PC/Clone with MCGA graphics board",
  873.        MCGA_XMAX, MCGA_YMAX, MCGA_VCHAR, MCGA_HCHAR,
  874.        MCGA_VTIC, MCGA_HTIC, options_null, MCGA_init, MCGA_reset,
  875.        MCGA_text, null_scale, MCGA_graphics, MCGA_move, MCGA_vector,
  876.        MCGA_linetype, MCGA_put_text, MCGA_text_angle, 
  877.        MCGA_justify_text, line_and_point, do_arrow, set_font_null}
  878.  
  879.     ,{"svga", "IBM PC/Clone with Super VGA graphics board",
  880.        SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR,
  881.        SVGA_VTIC, SVGA_HTIC, options_null, SVGA_init, SVGA_reset,
  882.        SVGA_text, null_scale, SVGA_graphics, SVGA_move, SVGA_vector,
  883.        SVGA_linetype, SVGA_put_text, SVGA_text_angle, 
  884.        SVGA_justify_text, do_point, do_arrow, set_font_null}
  885.  
  886.     ,{"vgalib", "IBM PC/Clone with VGA graphics board",
  887.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  888.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  889.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  890.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  891.        VGA_justify_text, do_point, do_arrow, set_font_null}
  892.  
  893.     ,{"vgamono", "IBM PC/Clone with VGA Monochrome graphics board",
  894.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  895.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  896.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  897.        VGAMONO_linetype, VGA_put_text, VGA_text_angle, 
  898.        VGA_justify_text, line_and_point, do_arrow, set_font_null}
  899. #else                    /* TURBO */
  900.  
  901. #ifdef ATT6300
  902.     ,{"att", "AT&T PC/6300 graphics",
  903.        ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
  904.        ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
  905.        ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
  906.        ATT_linetype, ATT_put_text, ATT_text_angle, 
  907.        null_justify_text, line_and_point, do_arrow, set_font_null}
  908. #endif
  909.  
  910.     ,{"cga", "IBM PC/Clone with CGA graphics board",
  911.        CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
  912.        CGA_VTIC, CGA_HTIC, options_null, CGA_init, CGA_reset,
  913.        CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
  914.        CGA_linetype, CGA_put_text, CGA_text_angle, 
  915.        null_justify_text, line_and_point, do_arrow, set_font_null}
  916.  
  917. #ifdef CORONA
  918.     ,{"corona325", "Corona graphics ???",
  919.        COR_XMAX, COR_YMAX, COR_VCHAR, COR_HCHAR,
  920.        COR_VTIC, COR_HTIC, options_null, COR_init, COR_reset,
  921.        COR_text, null_scale, COR_graphics, COR_move, COR_vector,
  922.        COR_linetype, COR_put_text, COR_text_angle, 
  923.        null_justify_text, line_and_point, do_arrow, set_font_null}
  924. #endif                    /* CORONA */
  925.  
  926.     ,{"egabios", "IBM PC/Clone with EGA graphics board (BIOS)",
  927.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  928.        EGA_VTIC, EGA_HTIC, options_null, EGA_init, EGA_reset,
  929.        EGA_text, null_scale, EGA_graphics, EGA_move, EGA_vector,
  930.        EGA_linetype, EGA_put_text, EGA_text_angle, 
  931.        null_justify_text, do_point, do_arrow, set_font_null}
  932.  
  933. #ifdef EGALIB
  934.     ,{"egalib", "IBM PC/Clone with EGA graphics board (LIB)",
  935.        EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  936.        EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
  937.        EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  938.        EGALIB_linetype, EGALIB_put_text, null_text_angle, 
  939.        null_justify_text, do_point, do_arrow, set_font_null}
  940. #endif
  941.  
  942. #ifdef HERCULES
  943.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  944.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  945.        HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
  946.        HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
  947.        HERC_linetype, HERC_put_text, HERC_text_angle, 
  948.        null_justify_text, line_and_point, do_arrow, set_font_null}
  949. #endif                    /* HERCULES */
  950.  
  951.     ,{"vgabios", "IBM PC/Clone with VGA graphics board (BIOS)",
  952.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  953.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  954.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  955.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  956.        null_justify_text, do_point, do_arrow, set_font_null}
  957.  
  958. #endif                    /* TURBO */
  959.  
  960. #endif               /* 0 */
  961.  
  962. #endif                    /* _Windows */
  963. #endif                    /* PC */
  964.  
  965. #ifdef __ZTC__         /* zortech C flashgraphics for 386 */
  966.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  967.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  968.        HERC_VTIC, HERC_HTIC, options_null, VGA_init, VGA_reset,
  969.        VGA_text, null_scale, HERC_graphics, VGA_move, VGA_vector,
  970.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  971.        VGA_justify_text, do_point, do_arrow, set_font_null}
  972.  
  973.     ,{"egamono", "IBM PC/Clone with monochrome EGA graphics board",
  974.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  975.        EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset,
  976.        VGA_text, null_scale, EGAMONO_graphics, VGA_move, VGA_vector,
  977.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  978.        VGA_justify_text, do_point, do_arrow, set_font_null}
  979.  
  980.     ,{"egalib", "IBM PC/Clone with color EGA graphics board",
  981.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  982.        EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset,
  983.        VGA_text, null_scale, EGA_graphics, VGA_move, VGA_vector,
  984.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  985.        VGA_justify_text, do_point, do_arrow, set_font_null}
  986.  
  987.     ,{"vgalib", "IBM PC/Clone with VGA graphics board",
  988.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  989.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  990.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  991.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  992.        VGA_justify_text, do_point, do_arrow, set_font_null}
  993.  
  994.     ,{"vgamono", "IBM PC/Clone with monochrome VGA graphics board",
  995.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  996.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  997.        VGA_text, null_scale, VGAMONO_graphics, VGA_move, VGA_vector,
  998.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  999.        VGA_justify_text, do_point, do_arrow, set_font_null}
  1000.  
  1001.     ,{"svgalib", "IBM PC/Clone with VESA Super VGA graphics board",
  1002.        SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR,
  1003.        SVGA_VTIC, SVGA_HTIC, options_null, VGA_init, VGA_reset,
  1004.        VGA_text, null_scale, SVGA_graphics, VGA_move, VGA_vector,
  1005.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  1006.        VGA_justify_text, do_point, do_arrow, set_font_null}
  1007.  
  1008.     ,{"ssvgalib", "IBM PC/Clone with VESA 256 color 1024 by 768 super VGA",
  1009.        SSVGA_XMAX, SSVGA_YMAX, SSVGA_VCHAR, SSVGA_HCHAR,
  1010.        SSVGA_VTIC, SSVGA_HTIC, options_null, VGA_init, VGA_reset,
  1011.        VGA_text, null_scale, SSVGA_graphics, VGA_move, VGA_vector,
  1012.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  1013.        VGA_justify_text, do_point, do_arrow, set_font_null}
  1014. #endif    /* __ZTC__ */
  1015.  
  1016. #ifdef AED
  1017.     ,{"aed512", "AED 512 Terminal",
  1018.        AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  1019.        AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
  1020.        AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
  1021.        AED_linetype, AED_put_text, null_text_angle, 
  1022.        null_justify_text, do_point, do_arrow, set_font_null}
  1023.     ,{"aed767", "AED 767 Terminal",
  1024.        AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  1025.        AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
  1026.        AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
  1027.        AED_linetype, AED_put_text, null_text_angle, 
  1028.        null_justify_text, do_point, do_arrow, set_font_null}
  1029. #endif
  1030.  
  1031. #ifdef AIFM
  1032.     ,{"aifm", "Adobe Illustrator 3.0 Format",
  1033.        AI_XMAX, AI_YMAX, AI_VCHAR, AI_HCHAR, 
  1034.        AI_VTIC, AI_HTIC, AI_options, AI_init, AI_reset, 
  1035.        AI_text, null_scale, AI_graphics, AI_move, AI_vector, 
  1036.        AI_linetype, AI_put_text, AI_text_angle, 
  1037.        AI_justify_text, do_point, do_arrow, set_font_null}
  1038. #endif
  1039.  
  1040. #ifdef APOLLO
  1041.        ,{"apollo", "Apollo Graphics Primitive Resource, rescaling of subsequent plots after window resizing",
  1042.        0, 0, 0, 0, /* APOLLO_XMAX, APOLLO_YMAX, APOLLO_VCHAR, APOLLO_HCHAR, are filled in at run-time */
  1043.        APOLLO_VTIC, APOLLO_HTIC, options_null, APOLLO_init, APOLLO_reset,
  1044.        APOLLO_text, null_scale, APOLLO_graphics, APOLLO_move, APOLLO_vector,
  1045.        APOLLO_linetype, APOLLO_put_text, APOLLO_text_angle,
  1046.        APOLLO_justify_text, line_and_point, do_arrow, set_font_null}
  1047. #endif
  1048.  
  1049. #ifdef GPR
  1050.        ,{"gpr", "Apollo Graphics Primitive Resource, fixed-size window",
  1051.        GPR_XMAX, GPR_YMAX, GPR_VCHAR, GPR_HCHAR,
  1052.        GPR_VTIC, GPR_HTIC, options_null, GPR_init, GPR_reset,
  1053.        GPR_text, null_scale, GPR_graphics, GPR_move, GPR_vector,
  1054.        GPR_linetype, GPR_put_text, GPR_text_angle,
  1055.        GPR_justify_text, line_and_point, do_arrow, set_font_null}
  1056. #endif
  1057.  
  1058. #ifdef BITGRAPH
  1059.     ,{"bitgraph", "BBN Bitgraph Terminal",
  1060.        BG_XMAX,BG_YMAX,BG_VCHAR, BG_HCHAR, 
  1061.        BG_VTIC, BG_HTIC, options_null, BG_init, BG_reset, 
  1062.        BG_text, null_scale, BG_graphics, BG_move, BG_vector,
  1063.        BG_linetype, BG_put_text, null_text_angle, 
  1064.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1065. #endif
  1066.  
  1067. #ifdef COREL
  1068.     ,{"corel","EPS format for CorelDRAW",
  1069.      CORELD_XMAX, CORELD_YMAX, CORELD_VCHAR, CORELD_HCHAR,
  1070.      CORELD_VTIC, CORELD_HTIC, COREL_options, COREL_init, COREL_reset,
  1071.      COREL_text, null_scale, COREL_graphics, COREL_move, COREL_vector,
  1072.      COREL_linetype, COREL_put_text, COREL_text_angle,
  1073.      COREL_justify_text, do_point, do_arrow, set_font_null}
  1074. #endif
  1075.  
  1076. #ifdef CGI
  1077.     ,{"cgi", "SCO CGI drivers (requires CGIDISP or CGIPRNT env variable)",
  1078.        CGI_XMAX, CGI_YMAX, 0, 0, 
  1079.        CGI_VTIC, 0, options_null, CGI_init, CGI_reset, 
  1080.        CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
  1081.        CGI_linetype, CGI_put_text, CGI_text_angle, 
  1082.        CGI_justify_text, CGI_point, do_arrow, set_font_null}
  1083.  
  1084.     ,{"hcgi", "SCO CGI drivers (hardcopy, requires CGIPRNT env variable)",
  1085.        CGI_XMAX, CGI_YMAX, 0, 0, 
  1086.        CGI_VTIC, 0, options_null, HCGI_init, CGI_reset, 
  1087.        CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
  1088.        CGI_linetype, CGI_put_text, CGI_text_angle, 
  1089.        CGI_justify_text, CGI_point, do_arrow, set_font_null}
  1090. #endif
  1091.  
  1092. #ifdef DEBUG
  1093.     ,{"debug", "debugging driver",
  1094.        DEBUG_XMAX, DEBUG_YMAX, DEBUG_VCHAR, DEBUG_HCHAR,
  1095.        DEBUG_VTIC, DEBUG_HTIC, options_null, DEBUG_init, DEBUG_reset,
  1096.        DEBUG_text, null_scale, DEBUG_graphics, DEBUG_move, DEBUG_vector,
  1097.        DEBUG_linetype, DEBUG_put_text, null_text_angle, 
  1098.        DEBUG_justify_text, line_and_point, do_arrow, set_font_null}
  1099. #endif
  1100.  
  1101. #ifdef DJSVGA
  1102.     ,{"svga", "IBM PC/Clone with Super VGA graphics board",
  1103.        DJSVGA_XMAX, DJSVGA_YMAX, DJSVGA_VCHAR, DJSVGA_HCHAR,
  1104.        DJSVGA_VTIC, DJSVGA_HTIC, options_null, DJSVGA_init, DJSVGA_reset,
  1105.        DJSVGA_text, null_scale, DJSVGA_graphics, DJSVGA_move, DJSVGA_vector,
  1106.        DJSVGA_linetype, DJSVGA_put_text, null_text_angle, 
  1107.        null_justify_text, do_point, do_arrow, set_font_null}
  1108. #endif
  1109.  
  1110. #ifdef DXF
  1111.     ,{"dxf", "dxf-file for AutoCad (default size 120x80)",
  1112.        DXF_XMAX,DXF_YMAX,DXF_VCHAR, DXF_HCHAR,
  1113.        DXF_VTIC, DXF_HTIC, options_null,DXF_init, DXF_reset,
  1114.        DXF_text, null_scale, DXF_graphics, DXF_move, DXF_vector,
  1115.        DXF_linetype, DXF_put_text, DXF_text_angle,
  1116.        DXF_justify_text, do_point, do_arrow, set_font_null}
  1117. #endif
  1118.  
  1119. #ifdef DXY800A
  1120.     ,{"dxy800a", "Roland DXY800A plotter",
  1121.        DXY_XMAX, DXY_YMAX, DXY_VCHAR, DXY_HCHAR,
  1122.        DXY_VTIC, DXY_HTIC, options_null, DXY_init, DXY_reset,
  1123.        DXY_text, null_scale, DXY_graphics, DXY_move, DXY_vector,
  1124.        DXY_linetype, DXY_put_text, DXY_text_angle, 
  1125.        null_justify_text, do_point, do_arrow, set_font_null}
  1126. #endif
  1127.  
  1128. #ifdef EEPIC
  1129.     ,{"eepic", "EEPIC -- extended LaTeX picture environment",
  1130.        EEPIC_XMAX, EEPIC_YMAX, EEPIC_VCHAR, EEPIC_HCHAR, 
  1131.        EEPIC_VTIC, EEPIC_HTIC, options_null, EEPIC_init, EEPIC_reset, 
  1132.        EEPIC_text, null_scale, EEPIC_graphics, EEPIC_move, EEPIC_vector, 
  1133.        EEPIC_linetype, EEPIC_put_text, EEPIC_text_angle, 
  1134.        EEPIC_justify_text, EEPIC_point, EEPIC_arrow, set_font_null}
  1135. #endif
  1136.  
  1137. #ifdef EMTEX
  1138. /* handled by latex below */
  1139. #endif
  1140.  
  1141. #ifdef EPS180
  1142.     ,{"epson_180dpi", "Epson LQ-style 180-dot per inch (24 pin) printers",
  1143.        EPS180XMAX, EPS180YMAX, EPSON180VCHAR, EPSON180HCHAR,
  1144.        EPSON180VTIC, EPSON180HTIC, options_null, EPSONinit, EPSONreset,
  1145.        EPS180text, null_scale, EPS180graphics, EPSONmove, EPSONvector,
  1146.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  1147.        null_justify_text, do_point, do_arrow, set_font_null}
  1148. #endif
  1149.  
  1150. #ifdef EPS60
  1151.     ,{"epson_60dpi", "Epson-style 60-dot per inch printers",
  1152.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  1153.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  1154.        EPS60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  1155.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  1156.        null_justify_text, do_point, do_arrow, set_font_null}
  1157. #endif
  1158.  
  1159. #ifdef EPSONP
  1160.     ,{"epson_lx800", "Epson LX-800, Star NL-10, NX-1000, PROPRINTER ...",
  1161.        EPSONXMAX, EPSONYMAX, EPSONVCHAR, EPSONHCHAR, 
  1162.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset, 
  1163.        EPSONtext, null_scale, EPSONgraphics, EPSONmove, EPSONvector, 
  1164.        EPSONlinetype, EPSONput_text, EPSON_text_angle, 
  1165.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1166. #endif
  1167.  
  1168. #ifdef EXCL
  1169.     ,{"excl", "Talaris EXCL Laser printer (also Talaris 1590 and others)",
  1170.        EXCL_XMAX,EXCL_YMAX, EXCL_VCHAR, EXCL_HCHAR, 
  1171.        EXCL_VTIC, EXCL_HTIC, options_null, EXCL_init,EXCL_reset, 
  1172.        EXCL_text, null_scale, EXCL_graphics, EXCL_move, EXCL_vector,
  1173.        EXCL_linetype,EXCL_put_text, null_text_angle, 
  1174.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1175. #endif
  1176.  
  1177.  
  1178. #ifdef FIG
  1179. #include "fig.trm"
  1180. #endif
  1181.  
  1182. #ifdef GPIC
  1183.     ,{"gpic", "GPIC -- Produce graphs in groff using the gpic preprocessor",
  1184.        GPIC_XMAX, GPIC_YMAX, GPIC_VCHAR, GPIC_HCHAR, 
  1185.        GPIC_VTIC, GPIC_HTIC, GPIC_options, GPIC_init, GPIC_reset, 
  1186.        GPIC_text, GPIC_scale, GPIC_graphics, GPIC_move, GPIC_vector, 
  1187.        GPIC_linetype, GPIC_put_text, GPIC_text_angle, 
  1188.        GPIC_justify_text, line_and_point, GPIC_arrow, set_font_null}
  1189. #endif
  1190.  
  1191. #ifdef HP26
  1192.     ,{"hp2623A", "HP2623A and maybe others",
  1193.        HP26_XMAX, HP26_YMAX, HP26_VCHAR, HP26_HCHAR,
  1194.        HP26_VTIC, HP26_HTIC, options_null, HP26_init, HP26_reset,
  1195.        HP26_text, null_scale, HP26_graphics, HP26_move, HP26_vector,
  1196.        HP26_linetype, HP26_put_text, HP26_text_angle, 
  1197.        null_justify_text, HP26_line_and_point, do_arrow, set_font_null}
  1198. #endif
  1199.  
  1200. #ifdef HP2648
  1201.     ,{"hp2648", "HP2648 and HP2647",
  1202.        HP2648XMAX, HP2648YMAX, HP2648VCHAR, HP2648HCHAR, 
  1203.        HP2648VTIC, HP2648HTIC, options_null, HP2648init, HP2648reset, 
  1204.        HP2648text, null_scale, HP2648graphics, HP2648move, HP2648vector, 
  1205.        HP2648linetype, HP2648put_text, HP2648_text_angle, 
  1206.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1207. #endif
  1208.  
  1209. #ifdef HP75
  1210.     ,{"hp7580B", "HP7580, and probably other HPs (4 pens)",
  1211.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  1212.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  1213.        HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  1214.        HP75_linetype, HPGL_put_text, HPGL_text_angle, 
  1215.        null_justify_text, do_point, do_arrow, set_font_null}
  1216. #endif
  1217.  
  1218. #ifdef HP7550
  1219.     ,{"hp7550", "HP7550, and probably newer HP plotter (8 pens)",
  1220.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  1221.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  1222.        HP7550_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  1223.        HP7550_linetype, HPGL_put_text, HPGL_text_angle, 
  1224.        null_justify_text, do_point, do_arrow, set_font_null}
  1225. #endif
  1226.  
  1227. #ifdef HP500C
  1228.       ,{"hp500c", "HP DeskJet 500c, [75 100 150 300] [rle tiff]",
  1229.        HP500C_75PPI_XMAX, HP500C_75PPI_YMAX, HP500C_75PPI_VCHAR,
  1230.        HP500C_75PPI_HCHAR, HP500C_75PPI_VTIC, HP500C_75PPI_HTIC, HP500Coptions,
  1231.        HP500Cinit, HP500Creset, HP500Ctext, null_scale,
  1232.        HP500Cgraphics, HP500Cmove, HP500Cvector, HP500Clinetype,
  1233.        HP500Cput_text, HP500Ctext_angle, null_justify_text, do_point,
  1234.        do_arrow, set_font_null}
  1235. #endif
  1236.  
  1237. #ifdef HPGL
  1238.     ,{"hpgl", "HP7475 and (hopefully) lots of others (6 pens)",
  1239.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  1240.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  1241.        HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  1242.        HPGL_linetype, HPGL_put_text, HPGL_text_angle, 
  1243.        null_justify_text, do_point, do_arrow, set_font_null}
  1244. #endif
  1245.  
  1246. #ifdef HPLJII
  1247.     ,{"hpljii", "HP Laserjet series II, [75 100 150 300]",
  1248.        HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
  1249.        HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
  1250.        HPLJIIinit, HPLJIIreset, HPLJIItext, null_scale,
  1251.        HPLJIIgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
  1252.        HPLJIIput_text, HPLJIItext_angle, null_justify_text, line_and_point,
  1253.        do_arrow, set_font_null}
  1254.     ,{"hpdj", "HP DeskJet 500, [75 100 150 300]",
  1255.        HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
  1256.        HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
  1257.        HPLJIIinit, HPLJIIreset, HPDJtext, null_scale,
  1258.        HPDJgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
  1259.        HPDJput_text, HPDJtext_angle, null_justify_text, line_and_point,
  1260.        do_arrow, set_font_null}
  1261. #endif
  1262.  
  1263. #ifdef HPPJ
  1264.     ,{"hppj", "HP PaintJet and HP3630 [FNT5X9 FNT9X17 FNT13X25]",
  1265.        HPPJ_XMAX, HPPJ_YMAX,
  1266.        HPPJ_9x17_VCHAR, HPPJ_9x17_HCHAR, HPPJ_9x17_VTIC, HPPJ_9x17_HTIC,
  1267.        HPPJoptions, HPPJinit, HPPJreset, HPPJtext, null_scale, HPPJgraphics,
  1268.        HPPJmove, HPPJvector, HPPJlinetype, HPPJput_text, HPPJtext_angle,
  1269.        null_justify_text, do_point, do_arrow, set_font_null}
  1270. #endif
  1271.  
  1272. #ifdef IMAGEN
  1273.     ,{"imagen", "Imagen laser printer",
  1274.        IMAGEN_XMAX, IMAGEN_YMAX, IMAGEN_VCHAR, IMAGEN_HCHAR, 
  1275.        IMAGEN_VTIC, IMAGEN_HTIC, IMAGEN_options, IMAGEN_init, IMAGEN_reset, 
  1276.        IMAGEN_text, IMAGEN_scale, IMAGEN_graphics, IMAGEN_move, 
  1277.        IMAGEN_vector, IMAGEN_linetype, IMAGEN_put_text, IMAGEN_text_angle,
  1278.        IMAGEN_justify_text, line_and_point, do_arrow, set_font_null}
  1279. #endif
  1280.  
  1281. #ifdef IRIS4D
  1282.     ,{"iris4d", "Silicon Graphics IRIS 4D Series Computer",
  1283.        IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR, 
  1284.        IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_options, IRIS4D_init, IRIS4D_reset, 
  1285.        IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
  1286.        IRIS4D_linetype, IRIS4D_put_text, null_text_angle, 
  1287.        null_justify_text, do_point, do_arrow, set_font_null}
  1288. #endif
  1289.  
  1290. #ifdef KERMIT
  1291.     ,{"kc_tek40xx", "MS-DOS Kermit Tek4010 terminal emulator - color",
  1292.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
  1293.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
  1294.        KTEK40Ctext, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
  1295.        KTEK40Clinetype, TEK40put_text, null_text_angle, 
  1296.        null_justify_text, do_point, do_arrow, set_font_null}
  1297.     ,{"km_tek40xx", "MS-DOS Kermit Tek4010 terminal emulator - monochrome",
  1298.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
  1299.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
  1300.        TEK40text, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
  1301.        KTEK40Mlinetype, TEK40put_text, null_text_angle, 
  1302.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1303. #endif
  1304.  
  1305. #ifdef LATEX
  1306. #include "latex.trm"
  1307. #endif
  1308.  
  1309. #ifdef LINUX
  1310. #include "linux.trm"
  1311. #endif
  1312.  
  1313. #ifdef LN03P
  1314.      ,{"ln03", "LN03-plus laser printer in tektronix (EGM) mode",
  1315.     LN03PXMAX, LN03PYMAX, LN03PVCHAR, LN03PHCHAR,
  1316.     LN03PVTIC, LN03PHTIC, options_null, LN03Pinit, LN03Preset,
  1317.     LN03Ptext, null_scale, TEK40graphics, LN03Pmove, LN03Pvector,
  1318.     LN03Plinetype, LN03Pput_text, null_text_angle,
  1319.     null_justify_text, line_and_point, do_arrow, set_font_null}
  1320. #endif
  1321.  
  1322. #ifdef MF
  1323.     ,{"mf", "Metafont plotting standard",
  1324.        MF_XMAX, MF_YMAX, MF_VCHAR, MF_HCHAR, 
  1325.        MF_VTIC, MF_HTIC, options_null, MF_init, MF_reset, 
  1326.        MF_text, null_scale, MF_graphics, MF_move, MF_vector, 
  1327.        MF_linetype, MF_put_text, MF_text_angle, 
  1328.        MF_justify_text, line_and_point, MF_arrow, set_font_null}
  1329. #endif
  1330.  
  1331. #ifdef MGR
  1332.     ,{"mgr", "Mgr window system",
  1333.     /* dimensions nominal, replaced during MGR_graphics call */
  1334.        MGR_XMAX, MGR_YMAX, MGR_VCHAR, MGR_HCHAR, 
  1335.        MGR_VTIC, MGR_HTIC, options_null, MGR_init, MGR_reset, 
  1336.        MGR_text, null_scale, MGR_graphics, MGR_move, MGR_vector,
  1337.        MGR_linetype, MGR_put_text, null_text_angle, 
  1338.        null_justify_text, do_point, do_arrow, set_font_null}
  1339. #endif
  1340.  
  1341. #ifdef MIF
  1342.     ,{"mif", "Frame maker MIF 3.00 format",
  1343.           MIF_XMAX, MIF_YMAX, MIF_VCHAR, MIF_HCHAR, 
  1344.         MIF_VTIC, MIF_HTIC, MIF_options, MIF_init, MIF_reset, 
  1345.        MIF_text, null_scale, MIF_graphics, MIF_move, MIF_vector, 
  1346.        MIF_linetype, MIF_put_text, MIF_text_angle, 
  1347.        MIF_justify_text, MIF_point, do_arrow, set_font_null}
  1348. #endif
  1349.  
  1350. #ifdef NEC
  1351.     ,{"nec_cp6", "NEC printer CP6, Epson LQ-800 [monocrome color draft]",
  1352.        NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
  1353.        NECVTIC, NECHTIC, NECoptions, NECinit, NECreset, 
  1354.        NECtext, null_scale, NECgraphics, NECmove, NECvector, 
  1355.        NEClinetype, NECput_text, NEC_text_angle, 
  1356.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1357. #endif
  1358.  
  1359. #ifdef NEXT
  1360.     ,{"next", "NeXTstep window system",
  1361.        NEXT_XMAX, NEXT_YMAX, NEXT_VCHAR, NEXT_HCHAR, 
  1362.        NEXT_VTIC, NEXT_HTIC, NEXT_options, NEXT_init, NEXT_reset, 
  1363.        NEXT_text, null_scale, NEXT_graphics, NEXT_move, NEXT_vector, 
  1364.        NEXT_linetype, NEXT_put_text, NEXT_text_angle, 
  1365.        NEXT_justify_text, NEXT_point, do_arrow, set_font_null}
  1366. #endif /* The PostScript driver with NXImage displaying the PostScript on screen */
  1367.  
  1368. #ifdef OKIDATA
  1369.     ,{"okidata", "OKIDATA 320/321 Standard",
  1370.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  1371.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  1372.        OKIDATAtext, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  1373.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  1374.        null_justify_text, do_point, do_arrow, set_font_null}
  1375. #endif
  1376.  
  1377. #ifdef OS2PM
  1378. #include "pm.trm"
  1379. #endif
  1380.  
  1381. #ifdef PBM
  1382.     ,{"pbm", "Portable bitmap [small medium large] [monochrome gray color]",
  1383.        PBM_XMAX, PBM_YMAX, PBM_VCHAR,
  1384.        PBM_HCHAR, PBM_VTIC, PBM_HTIC, PBMoptions,
  1385.        PBMinit, PBMreset, PBMtext, null_scale,
  1386.        PBMgraphics, PBMmove, PBMvector, PBMlinetype,
  1387.        PBMput_text, PBMtext_angle, null_justify_text, PBMpoint,
  1388.        do_arrow, set_font_null}
  1389. #endif
  1390.  
  1391. #ifdef PCL
  1392.  ,{"pcl5", "HP LaserJet III [mode] [font] [point]",
  1393.    PCL_XMAX, PCL_YMAX, HPGL2_VCHAR, HPGL2_HCHAR,
  1394.    PCL_VTIC, PCL_HTIC, PCL_options, PCL_init, PCL_reset,
  1395.    PCL_text, null_scale, PCL_graphics, HPGL2_move, HPGL2_vector,
  1396.    HPGL2_linetype, HPGL2_put_text, HPGL2_text_angle,
  1397.    HPGL2_justify_text, do_point, do_arrow, set_font_null}
  1398. #endif
  1399.  
  1400. #ifdef POSTSCRIPT
  1401.  
  1402. #include "post.trm" /* post */
  1403.  
  1404. # ifdef PSLATEX
  1405. # include "pslatex.trm"
  1406. # endif
  1407.  
  1408. #ifdef PSTEX
  1409.     ,{"pstex", "Generic TeX with PostScript \\specials",
  1410.     PSTEX_PS_XMAX, PSTEX_PS_YMAX, PSTEX_VCHAR, PSTEX_HCHAR,
  1411.     PSTEX_PS_VTIC, PSTEX_PS_HTIC, PSTEX_options, PSTEX_init, PSTEX_reset,
  1412.     PSTEX_text, PSTEX_scale, PSTEX_graphics, PS_move, PS_vector,
  1413.     PS_linetype, PSTEX_put_text, PSTEX_text_angle,
  1414.     PSTEX_justify_text, PS_point, do_arrow, PS_set_font}
  1415. #endif
  1416.  
  1417. #endif    /* POSTSCRIPT */
  1418.  
  1419. #ifdef GRASS              /* GRASS (geographic info system) monitor */
  1420. #include "term/grass.trm"
  1421. #endif /* GRASS */
  1422.  
  1423. #ifdef PRESCRIBE
  1424.     ,{"prescribe", "Prescribe - for the Kyocera Laser Printer",
  1425.     PRE_XMAX, PRE_YMAX, PRE_VCHAR, PRE_HCHAR, 
  1426.     PRE_VTIC, PRE_HTIC, options_null, PRE_init, PRE_reset, 
  1427.     PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
  1428.     PRE_linetype, PRE_put_text, null_text_angle, 
  1429.     PRE_justify_text, line_and_point, do_arrow, set_font_null}
  1430.     ,{"kyo", "Kyocera Laser Printer with Courier font",
  1431.     PRE_XMAX, PRE_YMAX, KYO_VCHAR, KYO_HCHAR, 
  1432.     PRE_VTIC, PRE_HTIC, options_null, KYO_init, PRE_reset, 
  1433.     PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
  1434.     PRE_linetype, PRE_put_text, null_text_angle, 
  1435.     PRE_justify_text, line_and_point, do_arrow, set_font_null}
  1436. #endif /* PRESCRIBE */
  1437.  
  1438. #ifdef    PSTRICKS
  1439.     ,{"pstricks", "LaTeX picture environment with PSTricks macros",
  1440.        PSTRICKS_XMAX, PSTRICKS_YMAX, PSTRICKS_VCHAR, PSTRICKS_HCHAR, 
  1441.        PSTRICKS_VTIC, PSTRICKS_HTIC, PSTRICKS_options, PSTRICKS_init, PSTRICKS_reset, 
  1442.        PSTRICKS_text, PSTRICKS_scale, PSTRICKS_graphics, PSTRICKS_move, PSTRICKS_vector, 
  1443.        PSTRICKS_linetype, PSTRICKS_put_text, PSTRICKS_text_angle, 
  1444.        PSTRICKS_justify_text, PSTRICKS_point, PSTRICKS_arrow, set_font_null}
  1445. #endif
  1446.     
  1447. #ifdef QMS
  1448.     ,{"qms", "QMS/QUIC Laser printer (also Talaris 1200 and others)",
  1449.        QMS_XMAX,QMS_YMAX, QMS_VCHAR, QMS_HCHAR, 
  1450.        QMS_VTIC, QMS_HTIC, options_null, QMS_init,QMS_reset, 
  1451.        QMS_text, null_scale, QMS_graphics, QMS_move, QMS_vector,
  1452.        QMS_linetype,QMS_put_text, null_text_angle, 
  1453.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1454. #endif
  1455.  
  1456. #ifdef REGIS
  1457. #include "regis.trm"
  1458. #endif
  1459.  
  1460. #ifdef RGIP
  1461.     ,{"rgip", "RGIP metafile (Uniplex). Option: fontsize (1-8)",
  1462.        RGIP_XMAX, RGIP_YMAX, RGIP_VCHAR, RGIP_HCHAR,
  1463.        RGIP_VTIC, RGIP_HTIC, RGIP_options, RGIP_init, RGIP_reset,
  1464.        RGIP_text, null_scale, RGIP_graphics, RGIP_move,
  1465.        RGIP_vector, RGIP_linetype, RGIP_put_text, RGIP_text_angle,
  1466.        RGIP_justify_text, RGIP_do_point, do_arrow, set_font_null}
  1467.     ,{"uniplex", "RGIP metafile (Uniplex). Option: fontsize (1-8)",
  1468.        RGIP_XMAX, RGIP_YMAX, RGIP_VCHAR, RGIP_HCHAR,
  1469.        RGIP_VTIC, RGIP_HTIC, RGIP_options, RGIP_init, RGIP_reset,
  1470.        RGIP_text, null_scale, RGIP_graphics, RGIP_move,
  1471.        RGIP_vector, RGIP_linetype, RGIP_put_text, RGIP_text_angle,
  1472.        RGIP_justify_text, RGIP_do_point, do_arrow, set_font_null}
  1473. #endif
  1474.  
  1475. #ifdef SELANAR
  1476.     ,{"selanar", "Selanar",
  1477.        TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
  1478.        TEK40VTIC, TEK40HTIC, options_null, SEL_init, SEL_reset, 
  1479.        SEL_text, null_scale, SEL_graphics, TEK40move, TEK40vector, 
  1480.        TEK40linetype, TEK40put_text, null_text_angle, 
  1481.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1482. #endif
  1483.  
  1484. #ifdef STARC
  1485.     ,{"starc", "Star Color Printer",
  1486.        STARCXMAX, STARCYMAX, STARCVCHAR, STARCHCHAR, 
  1487.        STARCVTIC, STARCHTIC, options_null, STARCinit, STARCreset, 
  1488.        STARCtext, null_scale, STARCgraphics, STARCmove, STARCvector, 
  1489.        STARClinetype, STARCput_text, STARC_text_angle, 
  1490.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1491. #endif
  1492.  
  1493. #ifdef SUN
  1494.     ,{"sun", "SunView window system",
  1495.        SUN_XMAX, SUN_YMAX, SUN_VCHAR, SUN_HCHAR, 
  1496.        SUN_VTIC, SUN_HTIC, options_null, SUN_init, SUN_reset, 
  1497.        SUN_text, null_scale, SUN_graphics, SUN_move, SUN_vector,
  1498.        SUN_linetype, SUN_put_text, null_text_angle, 
  1499.        SUN_justify_text, line_and_point, do_arrow, set_font_null}
  1500. #endif
  1501.  
  1502. #ifdef VWS
  1503.     ,{"VWS", "VAX Windowing System (UIS)",
  1504.            VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR,
  1505.            VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset,
  1506.            VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector,
  1507.            VWS_linetype, VWS_put_text, VWS_text_angle,
  1508.            VWS_justify_text, do_point, do_arrow, set_font_null}
  1509. #endif
  1510.  
  1511. #ifdef TANDY60
  1512.     ,{"tandy_60dpi", "Tandy DMP-130 series 60-dot per inch graphics",
  1513.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  1514.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  1515.        TANDY60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  1516.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  1517.        null_justify_text, do_point, do_arrow, set_font_null}
  1518. #endif
  1519.  
  1520. #ifdef T410X
  1521.     ,{"tek410x", "Tektronix 4106, 4107, 4109 and 420X terminals",
  1522.        T410XXMAX, T410XYMAX, T410XVCHAR, T410XHCHAR, 
  1523.        T410XVTIC, T410XHTIC, options_null, T410X_init, T410X_reset, 
  1524.        T410X_text, null_scale, T410X_graphics, T410X_move, T410X_vector, 
  1525.        T410X_linetype, T410X_put_text, T410X_text_angle, 
  1526.        null_justify_text, T410X_point, do_arrow, set_font_null}
  1527. #endif
  1528.  
  1529. #ifdef TEK
  1530. #ifndef CTEK
  1531.     ,{"tek40xx", "Tektronix 4010 and others; most TEK emulators",
  1532.        TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
  1533.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset, 
  1534.        TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector, 
  1535.        TEK40linetype, TEK40put_text, null_text_angle, 
  1536.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1537. #else
  1538.     ,{"tek40xx","Tektronix 4010 and others; most TEK emulators",
  1539.     TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
  1540.     TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset,
  1541.     TEK40text, null_scale, TEK40graphics, CTEK_move, CTEK_vector, 
  1542.     CTEK_linetype, TEK40put_text, null_text_angle, 
  1543.     null_justify_text, line_and_point, do_arrow, set_font_null}
  1544. #endif
  1545. #endif
  1546.  
  1547.     
  1548. #ifdef TEXDRAW
  1549.     ,{"texdraw", "LaTeX texdraw environment",
  1550.        TEXDRAW_XMAX, TEXDRAW_YMAX, TEXDRAW_VCHAR, TEXDRAW_HCHAR,
  1551.     TEXDRAW_VTIC, TEXDRAW_HTIC, options_null, TEXDRAW_init, TEXDRAW_reset,
  1552.     TEXDRAW_text, null_scale, TEXDRAW_graphics, TEXDRAW_move, TEXDRAW_vector,
  1553.     TEXDRAW_linetype, TEXDRAW_put_text, TEXDRAW_text_angle,
  1554.     TEXDRAW_justify_text, TEXDRAW_point, TEXDRAW_arrow, set_font_null}
  1555. #endif
  1556.   
  1557. #ifdef TGIF
  1558. #include "tgif.trm"
  1559. #endif
  1560.  
  1561. #ifdef TPIC
  1562.     ,{"tpic", "TPIC -- LaTeX picture environment with tpic \\specials",
  1563.        TPIC_XMAX, TPIC_YMAX, TPIC_VCHAR, TPIC_HCHAR, 
  1564.        TPIC_VTIC, TPIC_HTIC, TPIC_options, TPIC_init, TPIC_reset, 
  1565.        TPIC_text, null_scale, TPIC_graphics, TPIC_move, TPIC_vector, 
  1566.        TPIC_linetype, TPIC_put_text, TPIC_text_angle, 
  1567.        TPIC_justify_text, TPIC_point, TPIC_arrow, set_font_null}
  1568. #endif
  1569.  
  1570. #ifdef UNIXPLOT
  1571. #ifdef GNUGRAPH
  1572.     ,{"unixplot", "GNU plot(1) format [\042fontname\042 font_size]",
  1573.        UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR,
  1574.        UP_VTIC, UP_HTIC, UP_options, UP_init, UP_reset,
  1575.        UP_text, null_scale, UP_graphics, UP_move, UP_vector,
  1576.        UP_linetype, UP_put_text, UP_text_angle,
  1577.        UP_justify_text, line_and_point, do_arrow, set_font_null}
  1578. #else
  1579.     ,{"unixplot", "Unix plotting standard (see plot(1))",
  1580.        UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR, 
  1581.        UP_VTIC, UP_HTIC, options_null, UP_init, UP_reset, 
  1582.        UP_text, null_scale, UP_graphics, UP_move, UP_vector, 
  1583.        UP_linetype, UP_put_text, null_text_angle, 
  1584.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1585. #endif /* GNUGRAPH */
  1586. #endif
  1587.     
  1588. #ifdef UNIXPC
  1589.     ,{"unixpc", "AT&T 3b1 or AT&T 7300 Unix PC",
  1590.        uPC_XMAX, uPC_YMAX, uPC_VCHAR, uPC_HCHAR, 
  1591.        uPC_VTIC, uPC_HTIC, options_null, uPC_init, uPC_reset, 
  1592.        uPC_text, null_scale, uPC_graphics, uPC_move, uPC_vector,
  1593.        uPC_linetype, uPC_put_text, uPC_text_angle, 
  1594.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1595. #endif
  1596.  
  1597. #if 0
  1598. #ifdef EMXVGA
  1599. #ifdef EMXVESA
  1600.     ,{"vesa", "IBM PC/Clone with VESA SVGA graphics board [vesa mode]",
  1601.        EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  1602.        EMXVGA_VTIC, EMXVGA_HTIC, EMXVESA_options, EMXVESA_init, EMXVESA_reset,
  1603.        EMXVESA_text, null_scale, EMXVESA_graphics, EMXVGA_move, EMXVGA_vector,
  1604.        EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle, 
  1605.        null_justify_text, do_point, do_arrow, set_font_null}
  1606. #endif
  1607.     ,{"vgal", "IBM PC/Clone with VGA graphics board",
  1608.        EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  1609.        EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset,
  1610.        EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move, EMXVGA_vector,
  1611.        EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle, 
  1612.        null_justify_text, do_point, do_arrow, set_font_null}
  1613. #endif
  1614. #endif
  1615.  
  1616. #ifdef EMXVGA
  1617.     ,{"emxvga", "PC with SuperVGA running DOS or OS/2",
  1618.            EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  1619.            EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset,
  1620.            EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move,
  1621.        EMXVGA_vector, EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle,
  1622.            null_justify_text, do_point, do_arrow, set_font_null}
  1623. #endif
  1624.  
  1625. #ifdef V384
  1626.     ,{"vx384", "Vectrix 384 and Tandy color printer",
  1627.        V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR, 
  1628.        V384_VTIC, V384_HTIC, options_null, V384_init, V384_reset, 
  1629.        V384_text, null_scale, V384_graphics, V384_move, V384_vector, 
  1630.        V384_linetype, V384_put_text, null_text_angle, 
  1631.        null_justify_text, do_point, do_arrow, set_font_null}
  1632. #endif
  1633.  
  1634. #ifdef VTTEK
  1635.     ,{"vttek", "VT-like tek40xx terminal emulator",
  1636.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, TEK40HCHAR,
  1637.        TEK40VTIC, TEK40HTIC, options_null, VTTEK40init, VTTEK40reset,
  1638.        TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
  1639.        VTTEK40linetype, VTTEK40put_text, null_text_angle,
  1640.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1641. #endif
  1642.  
  1643. #ifdef _Windows
  1644.     ,{"windows", "Microsoft Windows",
  1645.        WIN_XMAX, WIN_YMAX, WIN_VCHAR, WIN_HCHAR, 
  1646.        WIN_VTIC, WIN_HTIC, WIN_options, WIN_init, WIN_reset, 
  1647.        WIN_text, null_scale, WIN_graphics, WIN_move, WIN_vector,
  1648.        WIN_linetype, WIN_put_text, WIN_text_angle, 
  1649.        WIN_justify_text, WIN_point, do_arrow, set_font_null}
  1650. #endif
  1651.  
  1652. #ifdef X11
  1653. #include "x11.trm"
  1654.    ,{"xlib", "X11 Window System (gnulib_x11 dump)",
  1655.        Xlib_XMAX, Xlib_YMAX, Xlib_VCHAR, Xlib_HCHAR, 
  1656.        Xlib_VTIC, Xlib_HTIC, options_null, Xlib_init, Xlib_reset, 
  1657.        Xlib_text, null_scale, Xlib_graphics, Xlib_move, Xlib_vector, 
  1658.        Xlib_linetype, Xlib_put_text, null_text_angle, 
  1659.        Xlib_justify_text, line_and_point, do_arrow, set_font_null}
  1660. #endif
  1661.  
  1662. #endif /* OLD_TERMINALS */
  1663.  
  1664. };
  1665.  
  1666. #define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry))
  1667.  
  1668.  
  1669. void list_terms()
  1670. {
  1671. register int i;
  1672.  
  1673.     fprintf(stderr,"\nAvailable terminal types:\n");
  1674.     for (i = 0; i < TERMCOUNT; i++)
  1675.         fprintf(stderr,"  %15s  %s\n",
  1676.                term_tbl[i].name, term_tbl[i].description);
  1677.     (void) putc('\n',stderr);
  1678. }
  1679.  
  1680.  
  1681. /* set_term: get terminal number from name on command line */
  1682. /* will change 'term' variable if successful */
  1683. struct termentry *
  1684. set_term(c_token)
  1685. int c_token;
  1686. {
  1687.     register struct termentry *t=NULL;
  1688.     char *input_name;
  1689.  
  1690.     if (!token[c_token].is_token)
  1691.      int_error("terminal name expected",c_token);
  1692.     input_name = input_line + token[c_token].start_index;
  1693.     t = change_term(input_name, token[c_token].length);
  1694.     if (!t)
  1695.      int_error("unknown or ambiguous terminal type; type just 'set terminal' for a list",
  1696.              c_token);
  1697.  
  1698.     /* otherwise the type was changed */
  1699.  
  1700.     return(t);
  1701. }
  1702.  
  1703. /* change_term: get terminal number from name and set terminal type */
  1704. /* returns NULL for unknown or ambiguous, otherwise is terminal driver pointer */
  1705. struct termentry *
  1706. change_term(name, length)
  1707.     char *name;
  1708.     int length;
  1709. {
  1710.     int i;
  1711.     struct termentry *t=NULL;
  1712.  
  1713.     for (i = 0; i < TERMCOUNT; i++) {
  1714.        if (!strncmp(name,term_tbl[i].name,length)) {
  1715.           if (t)
  1716.             return(NULL);    /* ambiguous */
  1717.           t = term_tbl+i;
  1718.        }
  1719.     }
  1720.  
  1721.     if (!t)            /* unknown */
  1722.      return(NULL);
  1723.  
  1724.     /* Success: set terminal type now */
  1725.  
  1726.     term = t;
  1727.     term_init = FALSE;
  1728.     name = term->name;
  1729.  
  1730.     if (term->scale != null_scale)
  1731.         fprintf(stderr, "Warning : scale interface is not null_scale - may not work with multiplot\n");
  1732.  
  1733.     /* check that optional fields are initialised to something */
  1734.     if (term->text_angle==0)
  1735.         term->text_angle = null_text_angle;
  1736.     if (term->justify_text==0)
  1737.         term->justify_text=null_justify_text;
  1738.     if (term->point==0)
  1739.         term->point = do_point;
  1740.     if (term->arrow==0)
  1741.         term->arrow = do_arrow;
  1742.     if (term->set_font==0)
  1743.         term->set_font = set_font_null;
  1744.     if (term->set_pointsize==0)
  1745.         term->set_pointsize = null_set_pointsize;
  1746.  
  1747.     /* Special handling for unixplot term type */
  1748.     if (!strncmp("unixplot",name,8)) {
  1749.        UP_redirect (2);  /* Redirect actual stdout for unixplots */
  1750.     } else if (unixplot) {
  1751.        UP_redirect (3);  /* Put stdout back together again. */
  1752.     }
  1753.  
  1754.     if (interactive)
  1755.      fprintf(stderr, "Terminal type set to '%s'\n", name);
  1756.  
  1757.     return(t);
  1758. }
  1759.  
  1760. /*
  1761.    Routine to detect what terminal is being used (or do anything else
  1762.    that would be nice).  One anticipated (or allowed for) side effect
  1763.    is that the global ``term'' may be set. 
  1764.    The environment variable GNUTERM is checked first; if that does
  1765.    not exist, then the terminal hardware is checked, if possible, 
  1766.    and finally, we can check $TERM for some kinds of terminals.
  1767.    A default can be set with -DDEFAULTTERM=myterm in the Makefile
  1768.    or #define DEFAULTTERM myterm in term.h
  1769. */
  1770. /* thanks to osupyr!alden (Dave Alden) for the original GNUTERM code */
  1771. void init_terminal()
  1772. {
  1773.     struct termentry *t;
  1774. #ifdef DEFAULTTERM
  1775.     char *term_name = DEFAULTTERM;
  1776. #else
  1777.     char *term_name = NULL;
  1778. #endif /* DEFAULTTERM */
  1779. #if (defined(__TURBOC__) && defined(MSDOS) && !defined(_Windows)) || defined(NEXT) || defined(SUN) || defined(X11)
  1780.     char *term = NULL;        /* from TERM environment var */
  1781. #endif
  1782. #ifdef X11
  1783.     char *display = NULL;
  1784. #endif
  1785.     char *gnuterm = NULL;
  1786.  
  1787.     /* GNUTERM environment variable is primary */
  1788.     gnuterm = getenv("GNUTERM");
  1789.     if (gnuterm != (char *)NULL) {
  1790.      term_name = gnuterm;
  1791.     }
  1792.     else {
  1793.        
  1794. #ifdef __ZTC__
  1795.       term_name = ztc_init();
  1796. #endif
  1797.  
  1798. #ifdef vms
  1799.        term_name = vms_init();
  1800. #endif
  1801.  
  1802. #ifdef NEXT
  1803.     term = getenv("TERM");
  1804.     if (term_name == (char *)NULL
  1805.         && term != (char *)NULL && strcmp(term,"next") == 0)
  1806.           term_name = "next";
  1807. #endif /* NeXT */
  1808.        
  1809. #ifdef SUN
  1810.        term = getenv("TERM");    /* try $TERM */
  1811.        if (term_name == (char *)NULL
  1812.           && term != (char *)NULL && strcmp(term, "sun") == 0)
  1813.         term_name = "sun";
  1814. #endif /* sun */
  1815.  
  1816. #ifdef _Windows
  1817.         term_name = "win";
  1818. #endif /* _Windows */
  1819.  
  1820. #ifdef GPR
  1821.    if (gpr_isa_pad()) term_name = "gpr";       /* find out whether stdout is a DM pad. See term/gpr.trm */
  1822. #else
  1823. #ifdef APOLLO
  1824.    if (apollo_isa_pad()) term_name = "apollo"; /* find out whether stdout is a DM pad. See term/apollo.trm */
  1825. #endif /* APOLLO */
  1826. #endif /* GPR    */
  1827.  
  1828. #ifdef X11
  1829.        term = getenv("TERM");    /* try $TERM */
  1830.        if (term_name == (char *)NULL
  1831.           && term != (char *)NULL && strcmp(term, "xterm") == 0)
  1832.         term_name = "x11";
  1833.        display = getenv("DISPLAY");
  1834.        if (term_name == (char *)NULL && display != (char *)NULL)
  1835.         term_name = "x11";
  1836.        if (X11_Display)
  1837.         term_name = "x11";
  1838. #endif /* x11 */
  1839.  
  1840. #if defined(AMIGA_SC_6_1) || defined(AMIGA_AC_5) || defined(AMIGA)
  1841.        term_name = "amiga";
  1842. #endif
  1843.  
  1844. #if defined(ATARI) || defined(MTOS)
  1845.        term_name = "atari";
  1846. #endif
  1847.  
  1848. #ifdef UNIXPC
  1849.            if (iswind() == 0) {
  1850.               term_name = "unixpc";
  1851.            }
  1852. #endif /* unixpc */
  1853.  
  1854. #ifdef CGI
  1855.        if (getenv("CGIDISP") || getenv("CGIPRNT"))
  1856.          term_name = "cgi";
  1857. #endif /*CGI */
  1858.  
  1859. #if defined(MSDOS) && defined(__EMX__)
  1860. #ifdef EMXVESA
  1861.        term_name = "vesa";
  1862. #else
  1863.        term_name = "vgal";
  1864. #endif
  1865. #endif
  1866.  
  1867. #ifdef DJGPP
  1868.         term_name = "svga";
  1869. #endif
  1870.  
  1871. #ifdef GRASS
  1872.         term_name = "grass";
  1873. #endif
  1874.  
  1875. #ifdef OS2
  1876.            term_name = "pm" ;
  1877.             /* EMX compiler has getcwd that can return drive */
  1878.            PM_init() ;
  1879. #endif /*OS2 */           
  1880.  
  1881. /* set linux terminal only if LINUX_setup was successfull, if we are on X11
  1882.    LINUX_setup has failed, also if we are logged in by network */
  1883. #ifdef LINUX
  1884.        if(LINUX_graphics_allowed)
  1885.          term_name = "linux";
  1886. #endif /* LINUX */
  1887.     }
  1888.  
  1889.     /* We have a name, try to set term type */
  1890.     if (term_name != NULL && *term_name != '\0') {
  1891.        if (change_term(term_name, (int)strlen(term_name)))
  1892.            return;
  1893.         fprintf(stderr, "Unknown or ambiguous terminal name '%s'\n", term_name);
  1894.     }
  1895.     change_term("unknown", 7);
  1896. }
  1897.  
  1898.  
  1899. #if defined(__ZTC__)
  1900. char *
  1901. ztc_init()
  1902. {
  1903.   int g_mode;
  1904.   char *term_name = NULL;
  1905.  
  1906.     g_mode = fg_init();
  1907.  
  1908.           switch (g_mode){
  1909.             case FG_NULL      :  fprintf(stderr,"Graphics card not detected or not supported.\n");
  1910.                                  exit(1);
  1911.             case FG_HERCFULL  :  term_name = "hercules";
  1912.                                  break;
  1913.             case FG_EGAMONO   :  term_name = "egamono";
  1914.                                  break;
  1915.             case FG_EGAECD      :  term_name = "egalib";
  1916.                                  break;
  1917.             case FG_VGA11      :  term_name = "vgamono";
  1918.                                  break;
  1919.             case FG_VGA12      :  term_name = "vgalib";
  1920.                                  break;
  1921.             case FG_VESA6A      :  term_name = "svgalib";
  1922.                                  break;
  1923.             case FG_VESA5      :  term_name = "ssvgalib";
  1924.                                  break;
  1925.             }
  1926.         fg_term();
  1927.   return(term_name);
  1928. }
  1929. #endif /* __ZTC__ */
  1930.  
  1931.  
  1932. /*
  1933.     This is always defined so we don't have to have command.c know if it
  1934.     is there or not.
  1935. */
  1936. #ifndef UNIXPLOT
  1937. void UP_redirect(caller) int caller; 
  1938. {
  1939.     caller = caller;    /* to stop Turbo C complaining 
  1940.                          * about caller not being used */
  1941. }
  1942. #else
  1943. void UP_redirect (caller)
  1944. int caller;
  1945. /*
  1946.     Unixplot can't really write to outfile--it wants to write to stdout.
  1947.     This is normally ok, but the original design of gnuplot gives us
  1948.     little choice.  Originally users of unixplot had to anticipate
  1949.     their needs and redirect all I/O to a file...  Not very gnuplot-like.
  1950.  
  1951.     caller:  1 - called from SET OUTPUT "FOO.OUT"
  1952.              2 - called from SET TERM UNIXPLOT
  1953.              3 - called from SET TERM other
  1954.              4 - called from SET OUTPUT
  1955. */
  1956. {
  1957.     switch (caller) {
  1958.     case 1:
  1959.     /* Don't save, just replace stdout w/outfile (save was already done). */
  1960.         if (unixplot)
  1961.             *(stdout) = *(outfile);  /* Copy FILE structure */
  1962.     break;
  1963.     case 2:
  1964.         if (!unixplot) {
  1965.             fflush(stdout);
  1966.             save_stdout = *(stdout);
  1967.             *(stdout) = *(outfile);  /* Copy FILE structure */
  1968.             unixplot = 1;
  1969.         }
  1970.     break;
  1971.     case 3:
  1972.     /* New terminal in use--put stdout back to original. */
  1973.         /* closepl(); */  /* This is called by the term. */
  1974.         fflush(stdout);
  1975.         *(stdout) = save_stdout;  /* Copy FILE structure */
  1976.         unixplot = 0;
  1977.     break;
  1978.     case 4:
  1979.     /*  User really wants to go to normal output... */
  1980.         if (unixplot) {
  1981.             fflush(stdout);
  1982.             *(stdout) = save_stdout;  /* Copy FILE structure */
  1983.         }
  1984.     break;
  1985.     }
  1986. }
  1987. #endif
  1988.  
  1989.  
  1990. /* test terminal by drawing border and text */
  1991. /* called from command test */
  1992. void test_term()
  1993. {
  1994.     register struct termentry *t = term;
  1995.     char *str;
  1996.     int x,y, xl,yl, i;
  1997.     unsigned int xmax, ymax;
  1998.     char label[MAX_ID_LEN];
  1999.     int scaling;
  2000.     int key_entry_height;
  2001.     int p_width;
  2002.  
  2003.     if (!term_init) {
  2004.        (*t->init)();
  2005.        term_init = TRUE;
  2006.     }
  2007.     screen_ok = FALSE;
  2008.     scaling = (*t->scale)(xsize, ysize);
  2009.     xmax = (unsigned int)(t->xmax * (scaling ? 1 : xsize));
  2010.     ymax = (unsigned int)(t->ymax * (scaling ? 1 : ysize));
  2011.     (*t->graphics)();
  2012.  
  2013.     p_width = pointsize * (t->h_tic);
  2014.     key_entry_height = pointsize * (t->v_tic) * 1.25;
  2015.     if (key_entry_height < (t->v_char) )
  2016.         key_entry_height = (t->v_char);
  2017.  
  2018.     /* border linetype */
  2019.     (*t->linetype)(-2);
  2020.     (*t->move)(0,0);
  2021.     (*t->vector)(xmax-1,0);
  2022.     (*t->vector)(xmax-1,ymax-1);
  2023.     (*t->vector)(0,ymax-1);
  2024.     (*t->vector)(0,0);
  2025.     (void) (*t->justify_text)(LEFT);
  2026.     (*t->put_text)(t->h_char*5,ymax-t->v_char*3,"Terminal Test");
  2027.     /* axis linetype */
  2028.     (*t->linetype)(-1);
  2029.     (*t->move)(xmax/2,0);
  2030.     (*t->vector)(xmax/2,ymax-1);
  2031.     (*t->move)(0,ymax/2);
  2032.     (*t->vector)(xmax-1,ymax/2);
  2033.     /* test width and height of characters */
  2034.     (*t->linetype)(-2);
  2035.     (*t->move)(  xmax/2-t->h_char*10,ymax/2+t->v_char/2);
  2036.     (*t->vector)(xmax/2+t->h_char*10,ymax/2+t->v_char/2);
  2037.     (*t->vector)(xmax/2+t->h_char*10,ymax/2-t->v_char/2);
  2038.     (*t->vector)(xmax/2-t->h_char*10,ymax/2-t->v_char/2);
  2039.     (*t->vector)(xmax/2-t->h_char*10,ymax/2+t->v_char/2);
  2040.     (*t->put_text)(xmax/2-t->h_char*10,ymax/2,
  2041.         "12345678901234567890");
  2042.     /* test justification */
  2043.     (void) (*t->justify_text)(LEFT);
  2044.     (*t->put_text)(xmax/2,ymax/2+t->v_char*6,"left justified");
  2045.     str = "centre+d text";
  2046.     if ((*t->justify_text)(CENTRE))
  2047.         (*t->put_text)(xmax/2,
  2048.                 ymax/2+t->v_char*5,str);
  2049.     else
  2050.         (*t->put_text)(xmax/2-strlen(str)*t->h_char/2,
  2051.                 ymax/2+t->v_char*5,str);
  2052.     str = "right justified";
  2053.     if ((*t->justify_text)(RIGHT))
  2054.         (*t->put_text)(xmax/2,
  2055.                 ymax/2+t->v_char*4,str);
  2056.     else
  2057.         (*t->put_text)(xmax/2-strlen(str)*t->h_char,
  2058.                 ymax/2+t->v_char*4,str);
  2059.     /* test text angle */
  2060.     str = "rotated ce+ntred text";
  2061.     if ((*t->text_angle)(1)) {
  2062.         if ((*t->justify_text)(CENTRE))
  2063.             (*t->put_text)(t->v_char,
  2064.                 ymax/2,str);
  2065.         else
  2066.             (*t->put_text)(t->v_char,
  2067.                 ymax/2-strlen(str)*t->h_char/2,str);
  2068.     }
  2069.     else {
  2070.         (void) (*t->justify_text)(LEFT);
  2071.         (*t->put_text)(t->h_char*2,ymax/2-t->v_char*2,"Can't rotate text");
  2072.     }
  2073.     (void) (*t->justify_text)(LEFT);
  2074.     (void) (*t->text_angle)(0);
  2075.     /* test tic size */
  2076.     (*t->move)( (unsigned int) (xmax/2+t->h_tic*(1+ticscale)) , (unsigned) 0);
  2077.     (*t->vector)( (unsigned int)(xmax/2+t->h_tic*(1+ticscale)),(unsigned int)(ticscale*t->v_tic));
  2078.     (*t->move)((unsigned int)(xmax/2),(unsigned int)(t->v_tic*(1+ticscale)));
  2079.     (*t->vector)((unsigned int)(xmax/2+ticscale*t->h_tic),(unsigned int)(t->v_tic*(1+ticscale)));
  2080.     (*t->put_text)((unsigned int)(xmax/2-10*t->h_char), (unsigned int)(t->v_tic*2+t->v_char/2),"test tics");
  2081.     /* test line and point types */
  2082.     x = xmax - t->h_char*6 - p_width;
  2083.     y = ymax - key_entry_height;
  2084.     for ( i = -2; y > key_entry_height; i++ ) {
  2085.         (*t->linetype)(i);
  2086.         /*    (void) sprintf(label,"%d",i);  Jorgen Lippert
  2087.         lippert@risoe.dk */
  2088.         (void) sprintf(label,"%d",i+1);
  2089.         if ((*t->justify_text)(RIGHT))
  2090.             (*t->put_text)(x,y,label);
  2091.         else
  2092.             (*t->put_text)(x-strlen(label)*t->h_char,y,label);
  2093.         (*t->move)(x+t->h_char,y);
  2094.         (*t->vector)(x+t->h_char*4,y);
  2095.         if ( i >= -1 )
  2096.             (*t->point)(x+t->h_char*5+p_width/2,y,i);
  2097.         y -= key_entry_height;
  2098.     }
  2099.     /* test some arrows */
  2100.     (*t->linetype)(0);
  2101.     x = xmax/4;
  2102.     y = ymax/4;
  2103.     xl = t->h_tic*5;
  2104.     yl = t->v_tic*5;
  2105.     (*t->arrow)(x,y,x+xl,y,TRUE);
  2106.     (*t->arrow)(x,y,x+xl/2,y+yl,TRUE);
  2107.     (*t->arrow)(x,y,x,y+yl,TRUE);
  2108.     (*t->arrow)(x,y,x-xl/2,y+yl,FALSE);
  2109.     (*t->arrow)(x,y,x-xl,y,TRUE);
  2110.     (*t->arrow)(x,y,x-xl,y-yl,TRUE);
  2111.     (*t->arrow)(x,y,x,y-yl,TRUE);
  2112.     (*t->arrow)(x,y,x+xl,y-yl,TRUE);
  2113.     /* and back into text mode */
  2114.     (*t->text)();
  2115. }
  2116.  
  2117.  
  2118. #if defined(MSDOS)||defined(g)||defined(MTOS)||defined(OS2)||defined(_Windows)||defined(DOS386)
  2119. /* output for some terminal types must be binary to stop non Unix computers
  2120.    changing \n to \r\n. 
  2121.    If the output is not STDOUT, the following code reopens outfile 
  2122.    with binary mode. */
  2123. void
  2124. reopen_binary()
  2125. {
  2126. char filename[MAX_ID_LEN+1];
  2127.  
  2128.     if (outfile!=stdout) {
  2129.         (void) fclose(outfile);
  2130.         (void) strcpy(filename,outstr+1);    /* remove quotes */
  2131.         filename[strlen(filename)-1] = '\0';
  2132. #ifdef _Windows
  2133.         if ( !stricmp(outstr,"'PRN'") )
  2134.             (void) strcpy(filename,win_prntmp);    /* use temp file for windows */
  2135. #endif
  2136.         if ( (outfile = fopen(filename,"wb")) == (FILE *)NULL ) {
  2137.             if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
  2138.                 os_error("cannot reopen file with binary type; output unknown",
  2139.                     NO_CARET);
  2140.             } 
  2141.             else {
  2142.     os_error("cannot reopen file with binary type; output reset to ascii", 
  2143.                     NO_CARET);
  2144.             }
  2145.         }
  2146. #if defined(__TURBOC__) && defined(MSDOS)
  2147. #ifndef _Windows
  2148.         if ( !stricmp(outstr,"'PRN'") )
  2149.         {
  2150.         /* Put the printer into binary mode. */
  2151.         union REGS regs;
  2152.             regs.h.ah = 0x44;    /* ioctl */
  2153.             regs.h.al = 0;        /* get device info */
  2154.             regs.x.bx = fileno(outfile);
  2155.             intdos(®s, ®s);
  2156.             regs.h.dl |= 0x20;    /* binary (no ^Z intervention) */
  2157.             regs.h.dh = 0;
  2158.             regs.h.ah = 0x44;    /* ioctl */
  2159.             regs.h.al = 1;        /* set device info */
  2160.             intdos(®s, ®s);
  2161.         }
  2162. #endif
  2163. #endif
  2164.     }
  2165. }
  2166. #endif
  2167.  
  2168. #ifdef vms
  2169. /* these are needed to modify terminal characteristics */
  2170. #include <descrip.h>
  2171. #include <iodef.h>
  2172. #include <ttdef.h>
  2173. #include <tt2def.h>
  2174. #include <dcdef.h>
  2175. #include <ssdef.h>
  2176. #include <stat.h>
  2177. #include <fab.h>
  2178. static unsigned short   chan;
  2179. static int  old_char_buf[3], cur_char_buf[3];
  2180. $DESCRIPTOR(sysoutput_desc,"SYS$OUTPUT");
  2181.  
  2182. char *vms_init()
  2183. /*
  2184.  *  Look first for decw$display (decterms do regis)
  2185.  *  Determine if we have a regis terminal
  2186.  * and save terminal characteristics
  2187. */
  2188. {
  2189.    /* Save terminal characteristics in old_char_buf and
  2190.    initialise cur_char_buf to current settings. */
  2191.    int i;
  2192.    if (getenv("DECW$DISPLAY"))
  2193.        return("x11");
  2194.    sys$assign(&sysoutput_desc,&chan,0,0);
  2195.    sys$qiow(0,chan,IO$_SENSEMODE,0,0,0,old_char_buf,12,0,0,0,0);
  2196.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  2197.    sys$dassgn(chan);
  2198.  
  2199.    /* Test if terminal is regis */
  2200.    if ((cur_char_buf[2] & TT2$M_REGIS) == TT2$M_REGIS) return("regis");
  2201.    return(NULL);
  2202. }
  2203.  
  2204. void
  2205. vms_reset()
  2206. /* set terminal to original state */
  2207. {
  2208.    int i;
  2209.    sys$assign(&sysoutput_desc,&chan,0,0);
  2210.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
  2211.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  2212.    sys$dassgn(chan);
  2213. }
  2214.  
  2215. void
  2216. term_mode_tek()
  2217. /* set terminal mode to tektronix */
  2218. {
  2219.    long status;
  2220.    if (outfile != stdout) return; /* don't modify if not stdout */
  2221.    sys$assign(&sysoutput_desc,&chan,0,0);
  2222.    cur_char_buf[0] = 0x004A0000 | DC$_TERM | (TT$_TEK401X<<8);
  2223.    cur_char_buf[1] = (cur_char_buf[1] & 0x00FFFFFF) | 0x18000000;
  2224.  
  2225.    cur_char_buf[1] &= ~TT$M_CRFILL;
  2226.    cur_char_buf[1] &= ~TT$M_ESCAPE;
  2227.    cur_char_buf[1] &= ~TT$M_HALFDUP;
  2228.    cur_char_buf[1] &= ~TT$M_LFFILL;
  2229.    cur_char_buf[1] &= ~TT$M_MECHFORM;
  2230.    cur_char_buf[1] &= ~TT$M_NOBRDCST;
  2231.    cur_char_buf[1] &= ~TT$M_NOECHO;
  2232.    cur_char_buf[1] &= ~TT$M_READSYNC;
  2233.    cur_char_buf[1] &= ~TT$M_REMOTE;
  2234.    cur_char_buf[1] |= TT$M_LOWER;
  2235.    cur_char_buf[1] |= TT$M_TTSYNC;
  2236.    cur_char_buf[1] |= TT$M_WRAP;
  2237.    cur_char_buf[1] &= ~TT$M_EIGHTBIT;
  2238.    cur_char_buf[1] &= ~TT$M_MECHTAB;
  2239.    cur_char_buf[1] &= ~TT$M_SCOPE;
  2240.    cur_char_buf[1] |= TT$M_HOSTSYNC;
  2241.  
  2242.    cur_char_buf[2] &= ~TT2$M_APP_KEYPAD;
  2243.    cur_char_buf[2] &= ~TT2$M_BLOCK;
  2244.    cur_char_buf[2] &= ~TT2$M_DECCRT3;
  2245.    cur_char_buf[2] &= ~TT2$M_LOCALECHO;
  2246.    cur_char_buf[2] &= ~TT2$M_PASTHRU;
  2247.    cur_char_buf[2] &= ~TT2$M_REGIS;
  2248.    cur_char_buf[2] &= ~TT2$M_SIXEL;
  2249.    cur_char_buf[2] |= TT2$M_BRDCSTMBX;
  2250.    cur_char_buf[2] |= TT2$M_EDITING;
  2251.    cur_char_buf[2] |= TT2$M_INSERT;
  2252.    cur_char_buf[2] |= TT2$M_PRINTER;
  2253.    cur_char_buf[2] &= ~TT2$M_ANSICRT;
  2254.    cur_char_buf[2] &= ~TT2$M_AVO;
  2255.    cur_char_buf[2] &= ~TT2$M_DECCRT;
  2256.    cur_char_buf[2] &= ~TT2$M_DECCRT2;
  2257.    cur_char_buf[2] &= ~TT2$M_DRCS;
  2258.    cur_char_buf[2] &= ~TT2$M_EDIT;
  2259.    cur_char_buf[2] |= TT2$M_FALLBACK;
  2260.  
  2261.    status = sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  2262.    if (status == SS$_BADPARAM) {
  2263.       /* terminal fallback utility not installed on system */
  2264.       cur_char_buf[2] &= ~TT2$M_FALLBACK;
  2265.       sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  2266.    }
  2267.    else {
  2268.       if (status != SS$_NORMAL)
  2269.          lib$signal(status,0,0);
  2270.    }
  2271.    sys$dassgn(chan);
  2272. }
  2273.  
  2274. void
  2275. term_mode_native()
  2276. /* set terminal mode back to native */
  2277. {
  2278.    int i;
  2279.    if (outfile != stdout) return; /* don't modify if not stdout */
  2280.    sys$assign(&sysoutput_desc,&chan,0,0);
  2281.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
  2282.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  2283.    sys$dassgn(chan);
  2284. }
  2285.  
  2286. void
  2287. term_pasthru()
  2288. /* set terminal mode pasthru */
  2289. {
  2290.    if (outfile != stdout) return; /* don't modify if not stdout */
  2291.    sys$assign(&sysoutput_desc,&chan,0,0);
  2292.    cur_char_buf[2] |= TT2$M_PASTHRU;
  2293.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  2294.    sys$dassgn(chan);
  2295. }
  2296.  
  2297. void
  2298. term_nopasthru()
  2299. /* set terminal mode nopasthru */
  2300. {
  2301.    if (outfile != stdout) return; /* don't modify if not stdout */
  2302.    sys$assign(&sysoutput_desc,&chan,0,0);
  2303.    cur_char_buf[2] &= ~TT2$M_PASTHRU;
  2304.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  2305.    sys$dassgn(chan);
  2306. }
  2307.  
  2308. void
  2309. reopen_binary()
  2310. /* close the file outfile outfile and reopen it with binary type
  2311.    if not already done or outfile == stdout */
  2312. {
  2313.    stat_t stat_buf;
  2314.    char filename[MAX_ID_LEN+1];
  2315.    if (outfile != stdout) { /* don't modify if not stdout */
  2316.       if (!fstat(fileno(outfile),&stat_buf)) {
  2317.          if (stat_buf.st_fab_rfm != FAB$C_FIX) {
  2318.             /* modify only if not already done */
  2319.             (void) fclose(outfile);
  2320.             (void) strcpy(filename,outstr+1);   /* remove quotes */
  2321.             filename[strlen(filename)-1] = '\0';
  2322.             (void) delete(filename);
  2323.             if ((outfile = fopen(filename,"wb","rfm=fix","bls=512","mrs=512"))
  2324.                 == (FILE *)NULL ) {
  2325.                if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
  2326.                  os_error("cannot reopen file with binary type; output unknown",
  2327.                            NO_CARET);
  2328.                }
  2329.                else {
  2330.           os_error("cannot reopen file with binary type; output reset to ascii",
  2331.                            NO_CARET);
  2332.                }
  2333.             }
  2334.          }
  2335.       }
  2336.       else{
  2337.          os_error("cannot reopen file with binary type; output remains ascii",
  2338.                   NO_CARET);
  2339.       }
  2340.    }
  2341. }
  2342.  
  2343. void
  2344. fflush_binary()
  2345. {
  2346.    typedef short int INT16;     /* signed 16-bit integers */
  2347.    register INT16 k;            /* loop index */
  2348.    if (outfile != stdout) {
  2349.        /* Stupid VMS fflush() raises error and loses last data block
  2350.           unless it is full for a fixed-length record binary file.
  2351.           Pad it here with NULL characters. */
  2352.        for (k = (INT16)((*outfile)->_cnt); k > 0; --k)
  2353.           putc('\0',outfile);
  2354.        fflush(outfile);
  2355.    }
  2356. }
  2357. #endif
  2358.